function geocodePosition(pos) {
geocoder.geocode({
latLng: pos
}, function (responses) {
if (responses && responses.length > 0) {
updateMarkerAddress(responses[0].formatted_address);
} else {
updateMarkerAddress('Cannot determine address at this location.');
}
});
}
I can get "formatted_address" using this code. How can I get the city, country and other information?
It's all within the responses object that is returned from the Maps API.
Here are the properties of the response object you're using - GeocoderResult
It's easier to visualise the results by seeing the expanded JSON on the Geocoding page
For example:
responses[0].address_components
would get you an array of objects containing address parts.