Wildhoney / Leaflet.FreeDraw

:earth_asia: FreeDraw allows the free-hand drawing of shapes on your Leaflet.js map layer – providing an intuitive and familiar UX for creating geospatial boundaries similar to Zoopla and others. Included out-of-the-box is the concaving of polygons, polygon merging and simplifying, as well as the ability to add edges and modify existing shapes.
https://freedraw.herokuapp.com/
MIT License
544 stars 103 forks source link

mouseDown event never unregistered causes javascript errors #170

Open kragoth opened 4 years ago

kragoth commented 4 years ago

In FreeDraw.js line 302 we have: map.on('mousedown touchstart', mouseDown);

This event handler is never cleaned up and there is no way for a user of this library to clean it up without removing all mousedown events. The onRemove(map) function should be removing the mousedown event handler so that if the layer is removed from the map it does not result in errors.

This is important when designing an app where draw can be toggled on or off.