Leaflet.LayerGroup.Collision
Leaflet.LayerGroup.Collision copied to clipboard
How to safely deactivate the plugin/remove from map
How do we safely remove the plugin in the map after we use it?
I tried removing it through: map.removeLayer(collisionLayer);, the labels are remove, but the rendering is messedup such that it affects other markers previously loaded on the map.
When I tried zooming, i encounter the following error after removing collisionLayer
Leaflet.LayerGroup.Collision.js:164 Uncaught TypeError: Cannot read property 'getZoom' of null
at e._onZoomEnd (Leaflet.LayerGroup.Collision.js:164)
at e.fire (Events.js:186)
at e._moveEnd (Map.js:1184)
at e.<anonymous> (Map.js:1628)
It should solve the issue:
onRemove: function (map) { this._map = null; map.off('zoomend', this._onZoomEnd, this); },