I am working with the leaflet api.Where i have added custom control for marker.
And i have a button which tends to remove all markers.
Problem
Through wrapping, i have to remove all markers but function not working....Browser not giving any console error, so i am in dark, didn't fully understand the structure of api.
Script
var markers = new L.FeatureGroup();
map.on('click', function markerPlace(e) {
//L.marker(e.latlng, { icon: markerIcon, draggable: true }).addTo(map);
marker = L.marker(e.latlng, { icon: markerIcon, draggable: true }).addTo(map);
markers.addLayer(marker);
map.off('click', markerPlace);
});
}).addTo(map);
//onClick this button we have to remove all marker
<button id="removeMarker">Remove Markers</button>
$('#removeMarker').click(function (e) {map.removeLayer(markers) });
If someone have idea about that please help or any kind of reference will be appreciated.Thanks for your time