我有一个侧边栏,我想在其上显示放置在 Google map 上的所有标记。当我通过拖动 map 更改 Veiwport 时。标记列表应刷新。
最佳答案
要首先获取所有标记,您必须找到当前视口(viewport)的边界,然后您必须循环所有标记并查看它们是否包含在边界中。下面是一个例子。
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");
}
关于google-maps - 如何找到当前在 Google Maps V3 上可见的所有标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20145609/