How to get city and postal code from google maps API.My code look like this
if (place.address_ponents) {
code = [place.address_ponents[0].types[0].postal_code];
alert(code);
document.getElementById('cityField').value = code;
}
but when i am trying this it alerts null.
Thanks in advance
How to get city and postal code from google maps API.My code look like this
if (place.address_ponents) {
code = [place.address_ponents[0].types[0].postal_code];
alert(code);
document.getElementById('cityField').value = code;
}
but when i am trying this it alerts null.
Thanks in advance
Share Improve this question asked Apr 15, 2013 at 6:59 JamesJames 872 gold badges3 silver badges13 bronze badges 3-
Is this all the code you have? There would need to be some kind of call to the Google API before
place
would have any value. – Mathijs Flietstra Commented Apr 15, 2013 at 7:03 - No.I am calling Google API and the map is working properly.My need is that when i select a place in one txt box i want to populate another textbox with postal code – James Commented Apr 15, 2013 at 7:08
- i will add my whole code – James Commented Apr 15, 2013 at 7:09
1 Answer
Reset to default 2Check the following links of SO and your problem's solution is in those question's answer:
- Lookup City and State by Zip Google Geocode Api
- How to look up ZIP/Postal Code by City using Google Maps API?
And this one is good for you. Have a look:
Google Maps API sometimes not returning PostalCode within AddressDetails
And read this tutorial:
how-to-find-which-state-a-zip-code-is-located-in-using-the-google-maps-api
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745249097a4618566.html
评论列表(0条)