最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c# - How to get city and postal code from google maps API? - Stack Overflow

programmeradmin3浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 2

Check the following links of SO and your problem's solution is in those question's answer:

  1. Lookup City and State by Zip Google Geocode Api
  2. 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

发布评论

评论列表(0)

  1. 暂无评论