谷歌地理编码api服务与邮政编码12593

时间:2017-12-07 23:48:34

标签: google-geocoding-api

我遇到了谷歌地理位置服务的问题。基本上我们将它用于邮政编码验证器,并且邮政编码有一个问题' 12593'。此邮政编码显示为在西班牙。 (见截图= http://prntscr.com/hkkafh

在这里查看xml     https://maps.googleapis.com/maps/api/geocode/xml?&address=12593

此邮政编码是基于美国的邮政编码,可在此处查看= https://www.google.com/search?num=100&q=us+zip+code+12593&oq=us+zip+code+12593(谷歌搜索结果。)

据我所知谷歌并不是邮政编码的好消息,但我希望谷歌能够理解这个邮政编码可能有两个独立的位置。

任何想法如何让api了解我在美国专门寻找邮政编码?

2 个答案:

答案 0 :(得分:1)

您尝试查找的邮政编码无法通过地理编码API进行访问。这附近可以到达:

https://maps.googleapis.com/maps/api/geocode/json?&components=country:US|postal_code:12516

要按邮政编码搜索并按国家/地区限制(例如美国),您必须使用components查询参数的子参数,例如上面的网址

...&components=country:US|postal_code:[YOUR PARAMETER]

(在https://developers.google.com/maps/documentation/geocoding/intro#ComponentFiltering上获得此参数信息)

答案 1 :(得分:0)

或者您可以使用 https://thezipcodes.com/ 从帐户部分获取 API 密钥。点击获取请求。我在这里找到了大部分数据。

https://thezipcodes.com/api/v1/search?zipCode={zipCode}&countryCode={2digitCountryCode}&apiKey={apiKey}

回复会像

{
    "success": true,
    "location": [{
      "zipCode": "13040",
      "country": "United States",
      "countryCode2": "US",
      "countryCode3": "USA",
      "state": "New York",
      "stateCode2": "NY",
      "city": "Cincinnatus",
      "county": "Cortland",
      "latitude": "42.564381",
      "longitude": "-75.934792",
      "timeZone": "EST — Eastern Standard Time"
    }]
}
相关问题