How to clear leaflet map of all markers and layers before adding new ones?

前端 未结 6 1543
遇见更好的自我
遇见更好的自我 2021-02-05 00:02

I have the fallowing code:

map: function (events) {
    var arrayOfLatLngs = [];
    var _this = this;

    // setup a marker group
    var markers = L.markerClu         


        
6条回答
  •  难免孤独
    2021-02-05 00:45

    You can clear all markers withought saving it

    map.eachLayer((layer) => {
      layer.remove();
    });
    

    from https://leafletjs.com/reference-1.0.3.html#map-event

提交回复
热议问题