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 badges1 Answer
Reset to default 5Looks to me like:
- there is not necessarily always a postal code in that response.
- 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