Answer the question
In order to leave comments, you need to log in
Leaflet - how to remove L.featureGroup from the map?
There is a map on leaflet, for example: https://jsfiddle.net/hc8bsd55/
Markers are added using this method:
L.featureGroup([marker_1, marker_2, marker_3]).addTo(mymap);
L.featureGroup([marker_1, marker_2, marker_3]).remove();
L.featureGroup([marker_1, marker_2, marker_3]).remove(mymap);
Answer the question
In order to leave comments, you need to log in
In your script, in the click handler, you create another featureGroup and immediately delete it. However, the first featureGroup you created remains.
Change the code to this and it will work:
// Добавляем маркеры на карту
var feature = L.featureGroup([marker_1, marker_2, marker_3]).addTo(mymap);
$(document).on('click', '.delete', function(e){
feature.remove();
return false;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question