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

javascript - Get zipcode with geo-autocomplete in google api v3 - Stack Overflow

programmeradmin1浏览0评论

This is the code I am using:

When I select an address in the geo-autoplete textfield, I want the corresponding zipcode to appear in another textfield, is this possible? I would be glad if someone can help me reach a solution.

After doing some research I found this:

var zip = address[address.length - 1].long_name = results[0].address_ponents;

But I am confused with how to use this code to get the zipcode?

Thanks!

This is the code I am using: https://google-developers.appspot./maps/documentation/javascript/examples/places-autoplete

When I select an address in the geo-autoplete textfield, I want the corresponding zipcode to appear in another textfield, is this possible? I would be glad if someone can help me reach a solution.

After doing some research I found this:

var zip = address[address.length - 1].long_name = results[0].address_ponents;

But I am confused with how to use this code to get the zipcode?

Thanks!

Share Improve this question edited Sep 2, 2012 at 17:11 Spudley 169k39 gold badges238 silver badges308 bronze badges asked Sep 2, 2012 at 14:45 A Mohammed HussainA Mohammed Hussain 2552 gold badges9 silver badges20 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Looks to me like:

  1. there is not necessarily always a postal code in that response.
  2. if there is one, the best way to get it is to search through the address_ponents of the result looking for one with the type "postal_code" and use that, like this example
发布评论

评论列表(0)

  1. 暂无评论