【leaflet】 leaflet移除地图上所有marker(layers)

文章原地址:https://blog.csdn.net/huangsheng_blog/article/details/77855890

eaflet批量移除地图上的marker可采用分组的方式,然后用分组批量清除,如下所示:

批量生成marker

  1. var layers=[];
  2. for(var i = 0;i< result.length;i++){
  3. var layer = new L.marker([ result[i].lat, result[i].lng ]);
  4. layers.push(layer);
  5. }

You may also like...