This class is used to obtain reverse geocodes (addresses) for user specified points. It does not use any caching mechanisme and is limited to 10 000 request per IP and per 24h. It uses both GDirections as GClientGeocoder.
All data is obtained by use of the Google Maps API only! Therefore Reverse Geocoding is only supported for those countries in which Google Maps supports Geocoding (GClientGeocoder) and Driving Directions (GDirections).
| Constructor | Description |
|---|---|
| GReverseGeocoder(map) | Creates a new instance of a reversegeocoder.
Note that the Additionally, the object contains thwo event listeners which you can intercept:
|
| Methods | Return Value | Description |
|---|---|---|
| setBaseCountry(country) | none | DEPRICATED: SHOULD NOT BE SET IN V1.0.2 OR ABOVE. Sets the reversegeocoder for use specified by the given country. GReverseGeocoder.setBaseCountry() should be called before any reverse geocoding is attempted. The country setting defaults to "Belguim". |
| reverseGeocode(point) | none | This method issues a new reverse geocode query. The parameter is a GLatLng point.
If successful the Placemark object is passed to the user-specified listener.
var listener = GEvent.addListener(reversegeocoder,"load",
function(placemark){
alert("The reverse geocoded address is "
+ placemark.address);
}
);
|
| getStatus() | object | Returns the status of the reverse geocode request. In GReverseGeocoder v1.0.2 the getStatus() method proxies the GDirections.getStatus() behavior. The returned object has the following form: { code: 200 request: "directions" } The status code can take any of the values defined in GGeoStatusCode. (Since Google Map API 2.81) |
| setExperimentalHouseNumber(true|false) | none | Since v1.0.2. This method toggles the house number support. THIS FEATURE IS EXPERIMENTAL AND USES MULTIPLE GClientGeocoder AND GDirections
REQUESTS WHICH COULD EXCESS THE GOOGLE REQUEST LIMITS. That's exactly why it is disabled (uncommented) in the full example.
Use it on own risk.
reversegeocoder.setExperimentalHouseNumber(true); |
| getPlacemarkProperty(placemark, propertyname) | object | Since v1.0.5. Returns the requested property of the placemark or null when not found.
This is useful since the returned placemark sturcture is data provider dependent.
GEvent.addListener(reversegeocoder, "load",
function(placemark) {
var postalcodenumber = reversegeocoder.getPlacemarkProperty(placemark,"PostalCodeNumber");
if (postalcodenumber != null) alert("Postal Code Number: " + postalcodenumber);
else alert("Postal Code Number Unknown");
}
);
|
| Events | Arguments | Description |
|---|---|---|
| load | placemark object | This event is fired when a successfull reverse geocode request was made. The placemark object looks like.
Notice however that the structure of the placemark is dependent on the used data provider. Use
the getPlacemarkProperty function to obtain a certain property.
{
"address": "1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA",
"AddressDetails": {
"Country": {
"CountryNameCode": "US",
"AdministrativeArea": {
"AdministrativeAreaName": "CA",
"SubAdministrativeArea": {
"SubAdministrativeAreaName": "Santa Clara",
"Locality": {
"LocalityName": "Mountain View",
"Thoroughfare": {
"ThoroughfareName": "1600 Amphitheatre Pkwy"
},
"PostalCode": {
"PostalCodeNumber": "94043"
}
}
}
}
},
"Accuracy": 8
},
"Point": {
"coordinates": [-122.083739, 37.423021, 0]
}
}
|
| error | none | This event is fired when an usuccessfull reverse geocode request was made |