want to show the postal code of a location from latitude and longitude of that location. below is my code.
function markerLocation() {
var currentLocation = marker.getPosition();
var geocoder = new google.maps.Geocoder();
var location = new google.maps.LatLng(currentLocation.lat(), currentLocation.lng());
geocoder.geocode({ 'latLng': location , function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var add = results[0].address_components[1][1];
document.getElementById('lat').value = add;
}
});
Here I want to show the postal code in lat. but when i use address_components it shows undefined. kindly help.