Leaflet.LayerGroup.Collision icon indicating copy to clipboard operation
Leaflet.LayerGroup.Collision copied to clipboard

How to safely deactivate the plugin/remove from map

Open vvavepacket opened this issue 7 years ago • 1 comments

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)

vvavepacket avatar Dec 09 '17 16:12 vvavepacket

It should solve the issue:

onRemove: function (map) { this._map = null; map.off('zoomend', this._onZoomEnd, this); },

dotevo avatar Sep 25 '18 20:09 dotevo