谷歌地图 API 地理编码
这个问题是关于谷歌地图 API 地理编码的,我能够对地址进行地理编码并显示位置,但这在地址有效时有效。
当它无效(有错误)时,现在,我会显示一条智能消息,表示检索位置时出错,但要求是显示距输入地址最近的可能位置。
如何获得下一个最佳位置的标记?
这是我尝试过的:
基于逗号分割地址,并对每个子字符串进行地理编码,并在第一个匹配上获取标记,但这导致了一些巨大的错误。
我现在想做的是:
使用雅虎地图 API 对邮政编码进行地理编码,但唯一的问题是我认为它不会接近用户输入的地址。
有什么解决办法吗?
This question is regarding the google Maps API geocoding, I'm able to geocode an address and show the location, but this works when the address is valid.
When it's not valid(there is an error),right now, I'm showing a smart message which says there is an error retrieving the location, but the requirement is to show the nearest possible location to the entered address.
How do I get the marker on next best location?
here's what I've tried:
Split the address, based on commas, and geocode each substring, and get the marker on the 1st match, but this resulted in some huge errors.
What I'm thinking of doing now is:
geocode the zip-code using yahoo maps API, but the only problem is I don't think it will be close to what the user has entered as his address.
Any solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Tarun,我不确定你使用的是哪个谷歌 API。但 Google 地理编码 api 确实允许部分地址搜索并返回按最适合排序的匹配项。因此显示最佳位置应该非常简单。看看下面这个链接。它返回 xml,但您可以通过将 url 中的 xml 替换为 json 来请求 json。您只需在此网址中插入您的部分地址即可。
http://maps.googleapis.com/maps /api/geocode/xml?address=holly%20hall&sensor=false
因此,如果此网址没有给您任何结果,那么可以安全地假设该地址不存在。
希望有帮助
Tarun , i am not sure which google api you are using. But Google geocoding api does allow for partial address searches and returns matches sorted by best fit. So displaying best location should be really simple. Take a look at this link below. It returns xml but you can ask for json by replacing xml in url with json. All you have to do insert your partial address in this url.
http://maps.googleapis.com/maps/api/geocode/xml?address=holly%20hall&sensor=false
So if this url doesnt give you any results, then its probably safe to assume that address doesn't exist.
Hope that hepls
我绝不是谷歌地图专家,但我会尝试这样的事情:
1)。获取邮政编码
2)。尝试找到该邮政编码内的街道
如果找到,请标记街道本身并对此感到满意。
I'm by no means an expert of Google Maps, but I would try something like this:
1). Get the zip code
2). Try to find the street within this zip code
If found, mark the street itself and be happy with that.