Returning The Uk Post Code Only Part Of A Google Maps Geocode Result
I have the following line of code from the Google Maps API V3 sample: https://google-developers.appspot.com/maps/documentation/javascript/examples/geocoding-reverse var full_addres
Solution 1:
The postcode is returned as a component of the address. Here is an example of how you might look for it in the result:
new google.maps.Geocoder().geocode({
'address': '20 Broadwick Street, London',
'latLng': google.maps.LatLng(51.5136905, -0.1354)
},
function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
address = results[0].address_components;
for (p = address.length-1; p >= 0; p--) {if (address[p].types.indexOf("postal_code") != -1) {
console.log(address[p].long_name);
}
}
}
}
);
Hope that helps.
Post a Comment for "Returning The Uk Post Code Only Part Of A Google Maps Geocode Result"