我可以从仅通过城市的 Google Geocoding API 获取地理编码信息吗?
我只需要获取给定城市的一些地理数据,我对地址不感兴趣(而且我不知道)。发送这样的请求:
http://maps.googleapis.com/maps/api/geocode/xml?address=fake,%20USA&sensor=false
将匹配美国某处带有“fake”一词的街道。 如果没有同名的城市,如何仅匹配城市并获得 ZERO_RESULTS
响应?
I just need to fetch some geo data for a given city, i'm not interested (and i don't know) the address. Sending a request like this:
http://maps.googleapis.com/maps/api/geocode/xml?address=fake,%20USA&sensor=false
will match a street with whe word fake in it, somewhere in USA. How can i match only cities and get ZERO_RESULTS
response if there is no city with that name?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
遗憾的是,您无法使用文档页面中的地理编码 API 执行此操作:
API将始终寻找特定的地址,如果它无法从您提供的字符串中找到完全匹配的地址,它将始终“尽最大努力”猜测您想要尝试找到的地址。只有当它无法做出合理的猜测时,才会返回
ZERO_RESULTS
。You can't do this with the Geocoding API unfortunately, from the docs page:
The API will always look for a specific address and if it can't find an exact match from the string you provide it will always make a 'best effort' guess as to what you meant to try and find one. Only if it can't make this reasonable guess wil it return
ZERO_RESULTS
.我也只是探索 API。如何使用如下链接
http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:US
地点等于 City 并将国家/地区指定为 US。它将返回零结果。但如果使用此
http:// maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:Nigeria
这将返回结果。
I also just explore the API.how about using link like below
http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:US
locality equal to City and stated the country as US.It will return zero result.But if using this
http://maps.googleapis.com/maps/api/geocode/xml?components=locality:fake|country:Nigeria
This will return the result.