How do I get Google Maps “Places API” to return ZIP code information?

*爱你&永不变心* 提交于 2020-01-02 01:07:11

问题


How do I get Google Maps "Places API" to return ZIP code information? In all the examples I find on the internet, none of them show results returning that contain a ZIP code. Is there a trick to this or is it not possible?


回答1:


This seems like it's returning a "postal code" (4 digits for some reason) in the address_component section:

https://developers.google.com/places/documentation/#PlaceDetailsRequests

However, I think what you're looking for is the Google Geocoding API:

Geocoding is the process of converting addresses (like "1600 Amphitheatre Parkway, Mountain View, CA") into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. The Google Geocoding API provides a direct way to access a geocoder via an HTTP request. Additionally, the service allows you to perform the converse operation (turning coordinates into addresses); this process is known as "reverse geocoding."

You can see in the JSON and XML responses a 5-digit postal code:

https://developers.google.com/maps/documentation/geocoding/#JSON




回答2:


check with: place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber



来源:https://stackoverflow.com/questions/11805704/how-do-i-get-google-maps-places-api-to-return-zip-code-information

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!