Hi everyone,
I need some help I'd like to get the postal code of some regions using
the latitude and the longitude of that place I know I've to use the
reverse geocoding and that's what I've been using but the problem is
to find the postal code from the returned answer here's the code I'm
using :
function codeLatLng(latlng) {
var input = latlng;
var latlngStr = input.split(",",2);
var lat = parseFloat(latlngStr[0]);
var lng = parseFloat(latlngStr[1]);
var latlng = new google.maps.LatLng(lat, lng);
geocoder.geocode({'latLng': latlng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
document.getElementById("airports").innerHTML+="<div
id='airport'><b>Lattitude, Longitude:</b>" + latlng + "<b>Country :</
b>" + results[0].address_components[6].long_name + "<b>Postal Code : </
b>" + results[0].address_components[7].long_name + "</div>";
}
} else {
alert("Geocoder failed due to: " + status);
}
}
but the problem is that not always
results[0].address_components[7].long_name contains the postal code.
So do you know how can I retrieve the postal code ?
Thank you
Sincerely
Wathek
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.