francoisromain / leaflet-markers-canvas

A Leaflet plugin to render many markers in a canvas instead of the DOM
GNU Affero General Public License v3.0
42 stars 15 forks source link

Removing MarkerCanvas doesnt appear to remove events #11

Open Michael-372 opened 2 years ago

Michael-372 commented 2 years ago

Im tryiong to figure out the right way to dynamically remove a L.MarkersCanvas() from the map but every time I remove it the events appear to persist.

Here is my code snippet:

const markersCanvas= new L.MarkersCanvas({ pane: 'markerPane' }).addTo(map);
// ...
// proceed to add a couple markers
// ...
map.removeLayer(markersCanvas);

The layer gets removed from the screen and the canvas gets removed from the DOM but as I mouse over the map im getting the following console errors which eventually freeze the entire application:

image