Closed rphlo closed 1 year ago
@rphlo It looks like you're right, feel free to submit a pull request to fix it.
👋 Raruto
I would do a pull request but I haven't found the right solution so far. Adding
onRemove: function(map) {
map.off('rotate', this._restyle.bind(this));
}
doesn't work.
For my project I added:
onRemove: function(map) {
map.off('rotate');
}
This work in my case, but would break functionalities for people who would have added their own event listener on 'rotate' event.
If so, can you attach some jsfiddle (or similar) with the tests you've already done?
Just to speed up debugging a little bit ☺️.
When adding the leaflet.control.rotate Control it add a listener on rotate map event
However when the control is removed the event listener is not removed from the map, and when calling map.setBearing or triggering the rotate event it triggers a JS error as the control does not exist anymore. Removing the event listener in onRemove function would solve this issue.