Class 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  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String BASE_URL
      Base URL
      static 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 mode
      static java.lang.String MODE_DRIVING
      Driving mode
      static java.lang.String MODE_TRANSIT
      Transit mode
      static java.lang.String MODE_WALKING
      Walking mode
      static java.lang.String STATICMAP_URL
      Deprecated.
      use getStaticMapURL(key)
      static java.lang.String UNITS_IMPERIAL
      Imperial units
      static java.lang.String UNITS_METRIC
      Metric units
    • Constructor Summary

      Constructors 
      Constructor Description
      GMapTool​(Grant g)
      Constructor
    • Method Summary

      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 address
      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
      static double distance​(org.json.JSONObject directions)
      Calculate distance for a directions JSON object
      GMapTool.Location[] geocodeAll​(java.lang.String address)
      Geocode from a given raw address
      static GMapTool.Location[] geocodeAll​(java.lang.String key, java.lang.String address)
      Geocode from a given raw address
      GMapTool.Location geocodeOne​(java.lang.String address)
      Geocode from a given raw address
      static GMapTool.Location geocodeOne​(java.lang.String key, java.lang.String address)
      Geocode from a given raw address
      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
      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
      java.lang.String getDirectionsURL()
      Get directions URL
      static java.lang.String getDirectionsURL​(java.lang.String key)
      Get directions URL
      org.json.JSONObject getGeocoding​(java.lang.String address)
      Get raw geocoding for address
      static org.json.JSONObject getGeocoding​(java.lang.String key, java.lang.String address)
      Get raw geocoding for address
      java.lang.String getGeocodingURL()
      Get geocoding URL
      static java.lang.String getGeocodingURL​(java.lang.String key)
      Get geocoding URL
      java.lang.String getJSURL()
      Get JavaScript URL
      static java.lang.String getJSURL​(java.lang.String key, java.lang.String lang)
      Get JavaScript URL
      java.lang.String getJSURLWithLibs​(java.lang.String[] libs)
      Get JavaScript URL with additional libraries
      static java.lang.String getJSURLWithLibs​(java.lang.String key, java.lang.String lang, java.lang.String[] libs)
      Get JavaScript URL with additional libraries
      java.lang.String getStaticMapURL()
      Get static map URL
      static java.lang.String getStaticMapURL​(java.lang.String key)
      Get static map URL
      java.lang.String getStreetViewURL()
      Get street view URL
      static java.lang.String getStreetViewURL​(java.lang.String key)
      Get street view URL
      static java.lang.String staticMapURL​(double lat, double lng, int zoom, int width, int height, boolean marker)
      Static map image URL
      static java.lang.String staticMapURL​(GMapTool.Location location, int zoom, int width, int height, boolean marker)
      Static map image URL
      static java.lang.String staticMapURL​(java.lang.String coords, int zoom, int width, int height, boolean marker)
      Static map image URL
      static java.lang.String streetviewURL​(java.lang.String location, int width, int height, int heading, int pitch)
      Streetview image URL
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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

      • 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 key
        libs - 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 key
        address - 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 key
        address - 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 key
        address - 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 key
        origin - Origin address
        destination - Destination address
        mode - 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 address
        destination - Destination address
        mode - Optional mode (MODE_*)
        units - Optional units (UNITS_*)
        Returns:
        JSON object
      • distance

        public static double distance​(org.json.JSONObject directions)
                               throws java.lang.Exception
        Calculate distance for a directions JSON object
        Parameters:
        directions - Directions JSON object
        Throws:
        java.lang.Exception
      • 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 key
        origin - Origin address or lat,lng
        destination - Destination address or lat,lng
        mode - 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,lng
        destination - Destination address or lat,lng
        mode - 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 - Latitude
        lng - 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 - Location
        zoom - 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 - Location
        width - Image width
        height - Image height
        heading - Heading angle
        pitch - Pitch angle
        Returns:
        Streetview image URL