使用Google地理编码api获取特定国家/地区的结果 [英] Get only country specific result using google geocode api

查看:205
本文介绍了使用Google地理编码api获取特定国家/地区的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用google geocode api来获取新加坡的邮政编码



我尝试了以下来获取数据:



(1) http: //maps.googleapis.com/maps/api/geocode/json?address=505468&a​​mp;sensor=false



(2)http://maps.googleapis.com/maps/api/geocode/json?address=Singapore %20505468& sensor = false



(3) http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&a​​mp;sensor=false&region=sg



但它从印度返回位置



HTTPS:// DEVE lopers.google.com/maps/documentation/geocoding/?hl=fr#RegionCodes



以其他任何方式只获取特定国家/地区(新加坡)的结果。



我试过以下它会返回正确结果

http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20133224&sensor=false 要将结果限制到特定国家/地区,请使用组件过滤功能。
$
b $ b

网址应为 http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&a​​mp;sensor=false&components=country:SG



但这不是问题,地理编码结果是错误的,因为结果将国家设置为 SG ,但位置错误(置于印度)。

我担心给定的地址(看起来邮编不存在),唯一可以做的就是向谷歌报告错误的结果。

I am using google geocode api for fetching lat long using postal code of singapore

I have tried following to fetch data:

(1) http://maps.googleapis.com/maps/api/geocode/json?address=505468&sensor=false

(2) http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=false

(3) http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=false&region=sg

But it returns location from India

https://developers.google.com/maps/documentation/geocoding/?hl=fr#RegionCodes

Any other way to get only country specific (Singapore) result.

I have tried following it returns correct result

http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20133224&sensor=false

解决方案

To restrict results to a specific country use the component-filtering.

The url should be http://maps.googleapis.com/maps/api/geocode/json?address=Singapore%20505468&sensor=false&components=country:SG

But that's not the issue here, the geocoder-result is wrong, because the result has the country set to SG, but the location is wrong(placed in india).

I'm afraid with the given address(it appears that the postcode doesn't exists), the only thing you can do is to report the wrong result to google.

这篇关于使用Google地理编码api获取特定国家/地区的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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