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

How to get city and postal code from google maps API.My code look like thisif (place.address_ponents) {

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745249097a4618566.html

相关推荐

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

    How to get city and postal code from google maps API.My code look like thisif (place.address_ponents) {

    8小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信