1

This is what I've done :

var geocoder = new google.maps.Geocoder();
var location = new google.maps.LatLng(45.930976,10.639744);

geocoder.geocode({ 'latLng': location  }, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
        alert(results[1].address_components[0].long_name);
    }
}); 

but I'd like to prefeer not using address_components[i] which parameter, due to the fact it could be different for each request. How is the parameter to get the city? (or location, or country, and so on...).

4

1 回答 1

3

Not sure if I'm reading the API right (Geocoding API doc), but it looks like it might be 'types:locality'

于 2012-04-04T17:34:48.833 回答