如何使用Google Maps API v.3将最近的标记找到可见地图区域中的已知点? [英] How to get the nearest marker to a know point in the visible map area with Google Maps API v.3?

查看:98
本文介绍了如何使用Google Maps API v.3将最近的标记找到可见地图区域中的已知点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已阅读此问题,但我有有些遗憾适用于我的情况,因为我有很多标记(atm〜5000,每天都在增长)。

在我的应用程序中,用户将他的标记(称为标记A )点击地图或通过地址进行地理编码;我必须知道在标记A的特定半径内是否有标记。

正如我所说,我无法遍历所有标记,它可能会杀死用户浏览器,如果可能的话,我很乐意避免Ajax请求来搜索我的数据库。



其实我通过 MarkerManager



有没有办法在地图可见区域的标记之间进行搜索?

解决方案

,我以迭代解决方案结束( demo here )。



为了减少要迭代的项目数量,我以状态为基础进行分割(目前已被捕获),也许将来我可以增加更多的分割。



如果它对其他人有用,我的'解决方案'意味着一个数组像:

  places = {
it:[
Rome ,
Venice
],
fr:[
Paris,
Lyon
],
es :[
Madrid,
Barcelona,
Girona

}

使用用户标记的Google地理编码可以获取状态('fr','it')查找地点的位置。


i've already read this question, but i have some regrets to apply in my situation becose i have many markers (atm ~5000, grown everyday).

In my application the user place his marker (lets call it marker A) clicking the map or via a geocode by address; I have to know if there is a marker in a specific radius of marker A.

As i said, i cant iterate throught all the markers, it will probably kill the user browser, and if possible i'll love to avoid ajax requests to search into my database.

Actually i insert the markers on the map via MarkerManager

Is there a way to search only between the markers in the map's visible area?

解决方案

After many many research, i ended with the iteration solution (demo here).

To decrease the number of items to iterate with, i divide in base of the state (at the moment is enaught), maybe in the future i can add further divisions.

If it can be usefull to someone else, my 'solution' implies an array like:

places = {
    "it":[
        "Rome",
        "Venice"
    ],
    "fr":[
        "Paris",
        "Lyon"
    ],
    "es":[
        "Madrid",
        "Barcelona",
        "Girona"
    ]
}

And a google geocode with the user marker coords to get the state ('fr', 'it') where to look for places.

这篇关于如何使用Google Maps API v.3将最近的标记找到可见地图区域中的已知点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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