【问题标题】:How to find all the markers which are currently visible on Google Maps V3?如何找到当前在 Google Maps V3 上可见的所有标记?
【发布时间】:2013-11-22 13:03:21
【问题描述】:

我有一个侧边栏,我想在其上显示放置在 Google 地图上的所有标记。当我通过拖动地图更改 Veiwport 时。标记列表应该会刷新。

【问题讨论】:

    标签: google-maps google-maps-markers


    【解决方案1】:

    要首先获取所有标记,您必须找到当前视口的边界,然后您必须循环所有标记并查看它们是否包含在边界中。下面是一个例子。

    var bounds =map.getBounds();
    
    for(var i = 0; i < markers.length; i++){ // looping through my Markers Collection        
    if(bounds.contains(markers[i].position))
     console.log("Marker"+ i +" - matched");
    }
    

    【讨论】:

    • 我相信问题是关于如何从地图本身获取当前在地图上可见的所有标记。我不知道这是否可能。
    猜你喜欢
    • 2013-02-24
    • 2011-02-04
    • 1970-01-01
    • 2010-12-05
    • 2012-06-19
    • 2015-08-01
    • 2011-02-23
    • 2016-08-22
    • 2011-05-02
    相关资源
    最近更新 更多