I am using Leaflet.js for a map. Now I want to remove added layers from the map. By clicking the input #button all checked checkboxes shall be changed to unchecked and all corre
I wrote the below example to show how to remove multiples geoJSON layer.
///adding geoJSON data
var myGeoJSON = L.geoJSON(myData, {
onEachFeature: function (feature, layer) {
layer.myTag = "myGeoJSON"
}
});
////// function to remove geoJSON layers
var removeMarkers = function() {
map.eachLayer( function(layer) {
if ( layer.myTag && layer.myTag === "myGeoJSON") {
map.removeLayer(layer)
}
});
}
//// calling function
removeMarkers();