Package com.simplicite.util.tools
Class GMapTool
- java.lang.Object
-
- com.simplicite.util.tools.GMapTool
-
public class GMapTool extends java.lang.Object
Google Maps toolbox
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GMapTool.Location
Location
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
BASE_URL
Base URLstatic java.lang.String
GEOCODING_URL
Deprecated.use getGeocodingURL(key)static java.lang.String
JS_URL
Deprecated.use getJSURL(key)static java.lang.String
MODE_BICYCLING
Bicycling modestatic java.lang.String
MODE_DRIVING
Driving modestatic java.lang.String
MODE_TRANSIT
Transit modestatic java.lang.String
MODE_WALKING
Walking modestatic java.lang.String
STATICMAP_URL
Deprecated.use getStaticMapURL(key)static java.lang.String
UNITS_IMPERIAL
Imperial unitsstatic java.lang.String
UNITS_METRIC
Metric units
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
distance(java.lang.String origin, java.lang.String destination, java.lang.String mode, java.lang.String units)
Get distance (km) from origin address to destination addressstatic double
distance(java.lang.String key, java.lang.String origin, java.lang.String destination, java.lang.String mode, java.lang.String units)
Get distance (km) from origin address to destination addressstatic double
distance(org.json.JSONObject directions)
Calculate distance for a directions JSON objectGMapTool.Location[]
geocodeAll(java.lang.String address)
Geocode from a given raw addressstatic GMapTool.Location[]
geocodeAll(java.lang.String key, java.lang.String address)
Geocode from a given raw addressGMapTool.Location
geocodeOne(java.lang.String address)
Geocode from a given raw addressstatic GMapTool.Location
geocodeOne(java.lang.String key, java.lang.String address)
Geocode from a given raw addressorg.json.JSONObject
getDirections(java.lang.String origin, java.lang.String destination, java.lang.String mode, java.lang.String units)
Get raw directions from origin address to destination addressstatic org.json.JSONObject
getDirections(java.lang.String key, java.lang.String origin, java.lang.String destination, java.lang.String mode, java.lang.String units)
Get raw directions from origin address to destination addressjava.lang.String
getDirectionsURL()
Get directions URLstatic java.lang.String
getDirectionsURL(java.lang.String key)
Get directions URLorg.json.JSONObject
getGeocoding(java.lang.String address)
Get raw geocoding for addressstatic org.json.JSONObject
getGeocoding(java.lang.String key, java.lang.String address)
Get raw geocoding for addressjava.lang.String
getGeocodingURL()
Get geocoding URLstatic java.lang.String
getGeocodingURL(java.lang.String key)
Get geocoding URLjava.lang.String
getJSURL()
Get JavaScript URLstatic java.lang.String
getJSURL(java.lang.String key, java.lang.String lang)
Get JavaScript URLjava.lang.String
getJSURLWithLibs(java.lang.String[] libs)
Get JavaScript URL with additional librariesstatic java.lang.String
getJSURLWithLibs(java.lang.String key, java.lang.String lang, java.lang.String[] libs)
Get JavaScript URL with additional librariesjava.lang.String
getStaticMapURL()
Get static map URLstatic java.lang.String
getStaticMapURL(java.lang.String key)
Get static map URLjava.lang.String
getStreetViewURL()
Get street view URLstatic java.lang.String
getStreetViewURL(java.lang.String key)
Get street view URLstatic java.lang.String
staticMapURL(double lat, double lng, int zoom, int width, int height, boolean marker)
Static map image URLstatic java.lang.String
staticMapURL(GMapTool.Location location, int zoom, int width, int height, boolean marker)
Static map image URLstatic java.lang.String
staticMapURL(java.lang.String coords, int zoom, int width, int height, boolean marker)
Static map image URLstatic java.lang.String
streetviewURL(java.lang.String location, int width, int height, int heading, int pitch)
Streetview image URLstatic java.lang.String
toLatLng(double lat, double lng)
To latitude;longitude string
-
-
-
Field Detail
-
BASE_URL
public static final java.lang.String BASE_URL
Base URL- See Also:
- Constant Field Values
-
GEOCODING_URL
@Deprecated public static final java.lang.String GEOCODING_URL
Deprecated.use getGeocodingURL(key)
-
STATICMAP_URL
@Deprecated public static final java.lang.String STATICMAP_URL
Deprecated.use getStaticMapURL(key)
-
JS_URL
@Deprecated public static final java.lang.String JS_URL
Deprecated.use getJSURL(key)
-
MODE_DRIVING
public static final java.lang.String MODE_DRIVING
Driving mode- See Also:
- Constant Field Values
-
MODE_WALKING
public static final java.lang.String MODE_WALKING
Walking mode- See Also:
- Constant Field Values
-
MODE_BICYCLING
public static final java.lang.String MODE_BICYCLING
Bicycling mode- See Also:
- Constant Field Values
-
MODE_TRANSIT
public static final java.lang.String MODE_TRANSIT
Transit mode- See Also:
- Constant Field Values
-
UNITS_METRIC
public static final java.lang.String UNITS_METRIC
Metric units- See Also:
- Constant Field Values
-
UNITS_IMPERIAL
public static final java.lang.String UNITS_IMPERIAL
Imperial units- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GMapTool
public GMapTool(Grant g)
Constructor- Parameters:
g
- Grant
-
-
Method Detail
-
toLatLng
public static java.lang.String toLatLng(double lat, double lng)
To latitude;longitude string- Parameters:
lat
- Latitudelng
- Longitude- Returns:
- Latitude;longitude string
-
getGeocodingURL
public static java.lang.String getGeocodingURL(java.lang.String key)
Get geocoding URL- Parameters:
key
- API key
-
getGeocodingURL
public final java.lang.String getGeocodingURL()
Get geocoding URL
-
getDirectionsURL
public static java.lang.String getDirectionsURL(java.lang.String key)
Get directions URL- Parameters:
key
- API key
-
getDirectionsURL
public final java.lang.String getDirectionsURL()
Get directions URL
-
getStaticMapURL
public static java.lang.String getStaticMapURL(java.lang.String key)
Get static map URL- Parameters:
key
- API key
-
getStaticMapURL
public final java.lang.String getStaticMapURL()
Get static map URL
-
getStreetViewURL
public static java.lang.String getStreetViewURL(java.lang.String key)
Get street view URL- Parameters:
key
- API key
-
getStreetViewURL
public final java.lang.String getStreetViewURL()
Get street view URL
-
getJSURL
public static java.lang.String getJSURL(java.lang.String key, java.lang.String lang)
Get JavaScript URL- Parameters:
key
- API key
-
getJSURL
public final java.lang.String getJSURL()
Get JavaScript URL
-
getJSURLWithLibs
public static java.lang.String getJSURLWithLibs(java.lang.String key, java.lang.String lang, java.lang.String[] libs)
Get JavaScript URL with additional libraries- Parameters:
key
- API keylibs
- Additional libraries (e.g. places, ...)
-
getJSURLWithLibs
public final java.lang.String getJSURLWithLibs(java.lang.String[] libs)
Get JavaScript URL with additional libraries- Parameters:
libs
- Additional libraries (e.g. places, ...)
-
getGeocoding
public static org.json.JSONObject getGeocoding(java.lang.String key, java.lang.String address)
Get raw geocoding for address- Parameters:
key
- API keyaddress
- Address- Returns:
- JSON object
-
getGeocoding
public org.json.JSONObject getGeocoding(java.lang.String address)
Get raw geocoding for address- Parameters:
address
- Address- Returns:
- JSON object
-
geocodeAll
public static GMapTool.Location[] geocodeAll(java.lang.String key, java.lang.String address)
Geocode from a given raw address- Parameters:
key
- API keyaddress
- Raw address- Returns:
- All matching location
-
geocodeAll
public GMapTool.Location[] geocodeAll(java.lang.String address)
Geocode from a given raw address- Parameters:
address
- Raw address- Returns:
- All matching location
-
geocodeOne
public static GMapTool.Location geocodeOne(java.lang.String key, java.lang.String address)
Geocode from a given raw address- Parameters:
key
- API keyaddress
- Raw address- Returns:
- First matching location
-
geocodeOne
public GMapTool.Location geocodeOne(java.lang.String address)
Geocode from a given raw address- Parameters:
address
- Raw address- Returns:
- First matching location
-
getDirections
public static org.json.JSONObject getDirections(java.lang.String key, java.lang.String origin, java.lang.String destination, java.lang.String mode, java.lang.String units)
Get raw directions from origin address to destination address- Parameters:
key
- API keyorigin
- Origin addressdestination
- Destination addressmode
- Optional mode (MODE_*)units
- Optional units (UNITS_*)- Returns:
- JSON object
-
getDirections
public org.json.JSONObject getDirections(java.lang.String origin, java.lang.String destination, java.lang.String mode, java.lang.String units)
Get raw directions from origin address to destination address- Parameters:
origin
- Origin addressdestination
- Destination addressmode
- Optional mode (MODE_*)units
- Optional units (UNITS_*)- Returns:
- JSON object
-
distance
public static double distance(org.json.JSONObject directions) throws HTTPException
Calculate distance for a directions JSON object- Parameters:
directions
- Directions JSON object- Throws:
HTTPException
-
distance
public static double distance(java.lang.String key, java.lang.String origin, java.lang.String destination, java.lang.String mode, java.lang.String units)
Get distance (km) from origin address to destination address- Parameters:
key
- API keyorigin
- Origin address or lat,lngdestination
- Destination address or lat,lngmode
- Optional mode (MODE_*)units
- Optional units (UNITS_*)- Returns:
- Distance in km
-
distance
public double distance(java.lang.String origin, java.lang.String destination, java.lang.String mode, java.lang.String units)
Get distance (km) from origin address to destination address- Parameters:
origin
- Origin address or lat,lngdestination
- Destination address or lat,lngmode
- Optional mode (MODE_*)units
- Optional units (UNITS_*)- Returns:
- Distance in km
-
staticMapURL
public static java.lang.String staticMapURL(double lat, double lng, int zoom, int width, int height, boolean marker)
Static map image URL- Parameters:
lat
- Latitudelng
- Longitude (e.g.zoom
- Zoom (e.g. 14)width
- Image width (px)height
- Image height (px)marker
- Display marker
-
staticMapURL
public static java.lang.String staticMapURL(GMapTool.Location location, int zoom, int width, int height, boolean marker)
Static map image URL- Parameters:
location
- Locationzoom
- Zoom (e.g. 14)width
- Image width (px)height
- Image height (px)marker
- Display marker
-
staticMapURL
public static java.lang.String staticMapURL(java.lang.String coords, int zoom, int width, int height, boolean marker)
Static map image URL- Parameters:
coords
- Geocoordinates (e.g. "48.86900000000001;2.3595125")zoom
- Zoom (e.g. 14)width
- Image width (px)height
- Image height (px)marker
- Display marker- Returns:
- Static map URL
-
streetviewURL
public static java.lang.String streetviewURL(java.lang.String location, int width, int height, int heading, int pitch)
Streetview image URL- Parameters:
location
- Locationwidth
- Image widthheight
- Image heightheading
- Heading anglepitch
- Pitch angle- Returns:
- Streetview image URL
-
-