问题描述
我正在使用此 API 调用 Google 地图来获取邮政编码的纬度和经度
I'm using this API call to Google Maps to get the latitude and longitude of a postal code
http://maps.googleapis.com/maps/api/geocode/json?address=2340&sensor=false
邮政编码在澳大利亚.此 API 调用返回世界各地的位置,地址中的邮政编码部分匹配.
The postal code is in Australia. This API call returns locations all around the world with partial matching postal codes in the address.
有没有可以用来将国家/地区设置为澳大利亚的参数?
Is there a parameter I can use to set the country to Australia?
谢谢
推荐答案
正确的方法不是通过区域偏置,而是使用 组件过滤:
The correct way to do this is not via region biasing but rather using component filtering:
https://maps.google.com/maps/api/geocode/json
?components=country:AU|postal_code:2340
&sensor=false
一些演示:
请注意,如果使用 components 参数,则不需要指定 address 参数.
Please note that if you use the components parameter, you don't need to specify the address parameter.
这篇关于Google Maps API Geocode Postal Code 并设置国家/地区代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!