java 如何让谷歌地图“Places API”返回邮政编码信息?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11805704/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I get Google Maps "Places API" to return ZIP code information?
提问by djangofan
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?
如何让谷歌地图“Places API”返回邮政编码信息?在我在互联网上找到的所有示例中,没有一个显示返回包含邮政编码的结果。这有什么窍门还是不可能?
采纳答案by Alex W
This seems like it's returning a "postal code" (4 digits for some reason) in the address_component
section:
这似乎在该address_component
部分返回了“邮政编码”(出于某种原因,为 4 位数字):
https://developers.google.com/places/documentation/#PlaceDetailsRequests
https://developers.google.com/places/documentation/#PlaceDetailsRequests
However, I think what you're looking for is the Google Geocoding API:
但是,我认为您正在寻找的是 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."
地理编码是将地址(如“1600 Amphitheatre Parkway, Mountain View, CA”)转换为地理坐标(如纬度 37.423021 和经度 -122.083739)的过程,您可以使用它来放置标记或定位地图。Google Geocoding API 提供了一种通过 HTTP 请求访问地理编码器的直接方法。此外,该服务允许您执行相反的操作(将坐标转换为地址);这个过程被称为“反向地理编码”。
You can see in the JSON and XML responses a 5-digit postal code:
您可以在 JSON 和 XML 响应中看到 5 位邮政编码:
https://developers.google.com/maps/documentation/geocoding/#JSON
https://developers.google.com/maps/documentation/geocoding/#JSON
回答by David Lyons Garcia
check with: place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber
检查: place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber