Vis*_*rma 5 google-maps google-maps-markers
我有一个侧边栏,我想在其上显示放置在Google地图上的所有标记.当我通过拖动地图来改变Veiwport.标记列表应该刷新.
要首先获取所有标记,您必须找到当前视口的边界,然后您必须循环所有标记并查看它们是否包含在边界中。下面是一个例子。
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");
}
Run Code Online (Sandbox Code Playgroud)