com.google.gwt.maps.client.geocode
Class Geocoder

java.lang.Object
  extended by com.google.gwt.maps.client.geocode.Geocoder

public final class Geocoder
extends java.lang.Object

A class for Geocoding Addresses through Google's Geocoding service over the Internet.


Constructor Summary
Geocoder()
          Creates a new instance of a geocoder that talks directly to Google servers.
Geocoder(GeocodeCache cache)
          Create a new geocoder object allowing a custom cache to be used.
 
Method Summary
 java.lang.String getBaseCountryCode()
          Returns the current country code in use by the given geocoder.
 GeocodeCache getCache()
          Returns the currently used geocode cache.
 void getLatLng(java.lang.String address, LatLngCallback callback)
          Sends a request to Google servers to geocode the specified address.
 void getLocations(LatLng point, LocationCallback callback)
          Sends a request to Google servers to reverse geocode the specified point.
 void getLocations(java.lang.String address, LocationCallback callback)
          Sends a request to Google servers to geocode the specified address.
 LatLngBounds getViewport()
          Returns the viewport for magnifying geocoding results within that geocoder.
 void reset()
          Resets the geocoder.
 void setBaseCountryCode(java.lang.String countryCode)
          Sets the geocoder to bias search results as if they were sent from the domain specified by the given country code top-level domain (ccTLD).
 void setViewport(LatLngBounds bounds)
          Sets the geocoder to magnify geocoding results within or near the given viewport.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Geocoder

public Geocoder()
Creates a new instance of a geocoder that talks directly to Google servers. A FactualGeocodeCache is used for results caching.


Geocoder

public Geocoder(GeocodeCache cache)
Create a new geocoder object allowing a custom cache to be used. When possible, aggressive caching is greatly encouraged as the geocoding service is computationally expensive and subject to daily limits by Google servers.

Parameters:
cache - An instance of a cache to associate with the geocoder.
See Also:
FactualGeocodeCache
Method Detail

getBaseCountryCode

public java.lang.String getBaseCountryCode()
Returns the current country code in use by the given geocoder. (If no country code is in effect, this method returns null.)

Returns:
the current country code in use by the given geocoder.

getCache

public GeocodeCache getCache()
Returns the currently used geocode cache.

Returns:
currently used geocode cache, or null, if no client-side caching is performed.

getLatLng

public void getLatLng(java.lang.String address,
                      LatLngCallback callback)
Sends a request to Google servers to geocode the specified address. If the address was successfully located, the user-specified callback function is invoked with a LatLng point. Otherwise, the callback function is given a null point. In case of ambiguous addresses, only the point for the best match is passed to the callback function.

Parameters:
address - the address to search for.
callback - methods to call when the query returns.

getLocations

public void getLocations(java.lang.String address,
                         LocationCallback callback)
Sends a request to Google servers to geocode the specified address. A reply that contains status code, and if successful, one or more Placemark objects, is passed to the user-specified callback function. Unlike the getLatLng(String,LatLngCallback) method, the callback function may determine the reasons for failure by examining the code value of the Status field.

Parameters:
address - the address to search for.
callback - methods to call when the query returns.

getLocations

public void getLocations(LatLng point,
                         LocationCallback callback)
Sends a request to Google servers to reverse geocode the specified point. A reply that contains status code, and if successful, one or more Placemark objects, is passed to the user-specified callback function. The callback function may determine the reasons for failure by examining the code value of the Status field.

Parameters:
point - the point to search for.
callback - methods to call when the query returns.

getViewport

public LatLngBounds getViewport()
Returns the viewport for magnifying geocoding results within that geocoder.

Returns:
the viewport for magnifying geocoding results within that geocoder.

reset

public void reset()
Resets the geocoder. In particular this method resets the client-side cache, if one is used by this geocoder.


setBaseCountryCode

public void setBaseCountryCode(java.lang.String countryCode)
Sets the geocoder to bias search results as if they were sent from the domain specified by the given country code top-level domain (ccTLD). Geocoding is only supported for those countries in which Google Maps itself supports geocoding. Most ccTLD codes are identical to ISO 3166-1 codes, with some notable exceptions. For example, Great Britain's top-level Internet domain (ccTLD) is "uk" (.co.uk) while its ISO 3166-1 code is "GR." Note that the default domain is the domain from which you initially load the Maps API.

Parameters:
countryCode - country code top-level domain (ccTLD). Country codes are case insensitive.

setViewport

public void setViewport(LatLngBounds bounds)
Sets the geocoder to magnify geocoding results within or near the given viewport. . Note that setting a viewport does not restrict results to that bounding box, though it will elevate them in priority.

Parameters:
bounds - the viewport expressed as a LatLngBounds rectangle