Class Geocoder

  • All Implemented Interfaces:
    Serializable

    public class Geocoder
    extends Object
    implements Serializable
    Geocoder. See: https://developers.google.com/maps/documentation/geocoding/
    Author:
    Thijs Vonk, Dieter Tremel
    See Also:
    Serialized Form
    • Constructor Detail

      • Geocoder

        public Geocoder​(com.fasterxml.jackson.databind.ObjectMapper mapper,
                        String apiKey)
        Configuration Constructor.
        If you have to customize the default ObjectMapper
        Parameters:
        mapper - your customized ObjectMapper
        apiKey - your Google Maps API-key
        See Also:
        Geocoder(String)
    • Method Detail

      • decode

        public GLatLng decode​(String response)
                       throws GeocoderException,
                              com.github.openjson.JSONException
        Decode an response of an geocoder request to POJOs.
        Following the successful mapping from JSON to POJO
        all hits are available in geocoderResult
        Parameters:
        response - - JSON response from Google Geocoder Service
        Returns:
        firstHit - First hit of geocoderResult
        Throws:
        GeocoderException - - When GeocoderStatus unequal to GeocoderStatus.OK
        com.github.openjson.JSONException - - The JSONException is thrown by the JSON.org classes when things are amiss.
      • encode

        public String encode​(String address)
        builds the google geo-coding url
        Parameters:
        address -
        Returns:
      • getGecoderResult

        public GeocoderResult getGecoderResult()
        Get the Result of the last geocoder Request
        Returns:
        the result of the last geocoder request
      • centerAndFitZoomForAdress

        public void centerAndFitZoomForAdress​(GMap map,
                                              String address)
                                       throws Exception
        Convenience method to center and fit the zoom for an address, on the given map.

        Example:

         GMap myMap = GMap("wicketId");
         new Geocoder().centerAndFitZoomForAdress(myMap, "Frankfurt am Main");
         
        Result:
        Frankfurt is centered and the zoom is suitable

        Parameters:
        map - - the map where the address should shown
        address - - address as string for the google geocoder
        Throws:
        Exception