public class Geocoder extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static String |
OUTPUT_JSON |
static String |
OUTPUT_XML |
Constructor and Description |
---|
Geocoder()
Default Constructor.
Create an ObjectMapper .The ObjectMapper ignore unknown properties when mapping from JSON to POJO.Use Geocoder(ObjectMapper) to customize |
Geocoder(com.fasterxml.jackson.databind.ObjectMapper mapper)
Configuration Constructor.
If you have to customize the default ObjectMapper |
Modifier and Type | Method and Description |
---|---|
void |
centerAndFitZoomForAdress(GMap map,
String address)
Convenience method to center and fit the zoom for an address, on the given map.
|
GLatLng |
decode(String response)
Decode an response of an geocoder request to POJOs.
Following the successful mapping from JSON to POJO all hits are available in geocoderResult |
String |
encode(String address)
builds the google geo-coding url
|
GLatLng |
geocode(String address)
Invoke a geocoder request to the GoogleMaps API.
Only return the first element of geocoderResult to be backward compatible.After succeful call of geocode(String) you can get all results from
geocoderResult |
GeocoderResult |
getGecoderResult()
Get the Result of the last geocoder Request
|
protected InputStream |
invokeService(String address)
fetches the url content
|
public static final String OUTPUT_XML
public static final String OUTPUT_JSON
public Geocoder()
ObjectMapper
.ObjectMapper
ignore unknown properties when mapping from JSON to POJO.Geocoder(ObjectMapper)
to customizepublic Geocoder(com.fasterxml.jackson.databind.ObjectMapper mapper)
ObjectMapper
Geocoder()
public GLatLng decode(String response) throws GeocoderException, org.apache.wicket.ajax.json.JSONException
geocoderResult
response
- - JSON respone from Google Geocoder ServicegeocoderResult
GeocoderException
- - When GeocoderStatus unequal to GeocoderStatus.OK
org.apache.wicket.ajax.json.JSONException
- - The JSONException is thrown by the JSON.org classes when things are amiss.public String encode(String address)
address
- public GLatLng geocode(String address) throws IOException
geocoderResult
to be backward compatible.geocode(String)
you can get all results from
geocoderResult
address
- - Requested addressGLatLng
- only first hit of the requestIOException
protected InputStream invokeService(String address) throws IOException
address
- IOException
public GeocoderResult getGecoderResult()
public void centerAndFitZoomForAdress(GMap map, String address) throws Exception
Example:
GMap myMap = GMap("wicketId"); new Geocoder().centerAndFitZoomForAdress(myMap, "Frankfurt am Main");Result:
map
- - the map where the address should shownaddress
- - address as string for the google geocoderException
Copyright © 2015. All rights reserved.