【leaflet】 leaflet移除地图上所有marker(layers)
文章原地址:https://blog.csdn.net/huangsheng_blog/article/details/77855890
eaflet批量移除地图上的marker可采用分组的方式,然后用分组批量清除,如下所示:
批量生成marker
-
var layers=[];
-
for(var i = 0;i< result.length;i++){
-
var layer = new L.marker([ result[i].lat, result[i].lng ]);
-
layers.push(layer);
-
}
-
var myGroup=L.layerGroup(layers);
-
maps.addLayer(myGroup);
批量移除
myGroup.clearLayers();
转载自:https://blog.csdn.net/zl15145428/article/details/80854398