且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

仅提供邮政编码的Google Maps API查询提供了不正确的结果

更新时间:2023-02-21 20:35:47

我建议使用组件过滤以获取邮政编码.

I would suggest using a component filtering in your Geocoder requests in order to obtain postal codes.

您的请求将被重写为

https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A42025%7Ccountry%3AUS&key=YOUR_API_KEY

https://maps.googleapis.com/maps/api/geocode/json?components=postal_code%3A42020%7Ccountry%3AUS&key=YOUR_API_KEY

两个请求都将预期结果返回给我.您还可以在Geocoder工具中看到它:

Both requests return expected results to me. You can also see it in the Geocoder tool:

我希望这会有所帮助!