Google地理编码API返回ZERO_RESULTS作为邮政编码 [英] Google geocoding API returns ZERO_RESULTS for postal code

查看:135
本文介绍了Google地理编码API返回ZERO_RESULTS作为邮政编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Maps API对用户输入的数据进行地理编码,但是澳大利亚邮政编码"2010"出现错误

I am trying to geocode user entered data using the Google maps API, and got an error for the Australian postal code "2010"

maps.google.com/maps/api/geocode/json?components=country:AU|postal_code:2010

maps.google.com/maps/api/geocode/json?components=country:AU|postal_code:2010

但是,如果我在Google地图中搜索,就会得到结果.我在请求中做错了吗?

However, if I search in Google maps, I get a result. Am I doing something wrong in my request?

推荐答案

您的请求完全可以,但是不幸的是,Google在搜索4位数的邮政编码时遇到问题.此错误已在Google问题跟踪器中报告,您可以在此处查看它:

Your request is completely OK, but unfortunately, Google experience issues with searching 4-digit postal codes. This bug has already been reported in Google issue tracker and you can see it here:

难以对4位邮政编码进行地理编码(AT,AU,BE,DK,NZ,SI)

我建议给该错误加注星标,以添加您的投票并订阅来自Google的进一步通知.

I would suggest starring the bug to add your vote and subscribe to further notifications from Google.

您还可以看到Google建议的解决方法是使用类型为(region)和国家/地区组成部分过滤器的地点自动完成请求.

Also you can see that suggested workaround by Google is using place autocomplete request with types (region) and country components filter.

因此,您可以运行以下查询

So, in your case you can run the following query

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=2010&types=(regions)&components=country%3AAU&key=YOUR_API_KEY

它将返回邮政编码为2010的地点ID:ChIJ3QyubXuuEmsREIe6P2t9ARw

It will return a place ID for postal code 2010: ChIJ3QyubXuuEmsREIe6P2t9ARw

并且您可以将地理编码与地点ID结合使用以获取所需的信息

And you can use geocoding with place ID to get required information

https://maps.googleapis.com/maps/api/geocode/json?place_id=ChIJ3QyubXuuEmsREIe6P2t9ARw&key=YOUR_API_KEY

我希望这会有所帮助!

这篇关于Google地理编码API返回ZERO_RESULTS作为邮政编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆