我使用 Google 提供的简单网址来查找邮政编码。
http://maps.googleapis.com/maps/api/geocode/json?address=90210&sensor=true
此 URL 将返回全世界的结果,但如何将这些结果限制为仅限美国?我查了一下,但找不到任何东西。当可能有办法添加到 URL 并获取:
时,我不想编写过多的代码来确保不存在任何美国地址。 {
"results" : [],
"status" : "ZERO_RESULTS"
}
如果根本没有结果,这就是 API 返回的内容。容易多了。
最佳答案
您可以使用component filtering并使用country
和postal_code
组件
http://maps.googleapis.com/maps/api/geocode/json?sensor=true&components=country:US|postal_code:90210
关于geocoding - Google Geocode API 仅限美国结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19716528/