如何在谷歌地图上找到离我最近的点?
我正在编写一个 Android 应用程序,该应用程序应该从我的 SQL 服务器下载一堆地址,对它们进行反向地理编码,将它们全部与我当前的位置进行比较,然后返回最接近我的地址,不是几何上的,而是距离我最近的地址。我距离最近的车程。
我已经设法让反向地理编码工作,但是当我运行我的程序几次时,我在谷歌上遇到了 OVER_QUERY_LIMIT 。不用说,我的数据库中有相当多的地址。
我知道我可以通过快速而肮脏的方式来做到这一点,只需通过比较我当前位置和我的地址的纬度和经度来查看哪个地址离我最近,而不是将其与实际驾驶距离进行比较。问题在于,该应用程序将在有很多湖泊需要行驶的地区使用,并且使用该方法可能会返回相当多的愚蠢结果。
我怎样才能避免这种情况反复发生?我可以向谷歌展示我的所有地址并进行一次比较吗?我真的需要这方面的帮助。
I am writing an Android-application that is supposed to download a bunch of addresses from my SQL-server, reverse geocode them, compare them all to my current location and return the one that is closest to me, not geometrically, but the one that I am the shortest driving distance from.
I have managed to get the reversed geocoding to work, but when I run my program a few times, I hit the OVER_QUERY_LIMIT on google. Needless to say, there are quite a few addresses in my database.
I understand that I could do this the quick and dirty way and just see which address is nearest to me by comparing the latitude and longitude of my current position and that of my addresses as opposed to comparing it to the actual driving distance. The problem with this is that this application will be used in a region where there are quite a lot of lakes to drive around and using that method will likely return quite a few stupid results.
How can I keep this from happening over and over? Can I present google with a view of all my addresses and just do a comparison once? I really need help with this one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,您必须查询路由服务(不一定是 Google 地图,据我所知,还有 Cloudmade为您提供路线;肯定还有更多)获取前往您周围每个兴趣点的行车路线,然后选择最近的一个。这是一个非常糟糕的做法,因为您的请求数量非常有限。
根据 Google Maps API TOS(第 10.1.3 段),您并不总是允许这样做。
在类似的情况下,我所做的是存储所有 POI 的坐标,并仅通过纬度/经度范围查找最近的坐标。
Actually, you will have to query a routing service (not necessarily Google Maps, to my knowledge also Cloudmade provides you with routing; there definitely are more) to get driving directions to each of the Points Of Interest around you and then select the closest one. This is a very bad practice, as you are very limited with the request amount.
According to the Google Maps API TOS (paragraph 10.1.3) you are not always allowed to do that.
What I did in a similar case was to store the coordinates for all POI, and look up the closest ones just by range of lat/lng.