diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js index 21209d063..f3961dd16 100644 --- a/src/MarkerCluster.Spiderfier.js +++ b/src/MarkerCluster.Spiderfier.js @@ -320,12 +320,17 @@ L.MarkerClusterGroup.include({ _spiderfierOnRemove: function () { this._map.off('click', this._unspiderfyWrapper, this); this._map.off('zoomstart', this._unspiderfyZoomStart, this); + this._map.off('zoomanim', this._unspiderfyZoomAnim, this); }, //On zoom start we add a zoomanim handler so that we are guaranteed to be last (after markers are animated) //This means we can define the animation they do rather than Markers doing an animation to their actual location _unspiderfyZoomStart: function () { + if (!this._map) { //May have been removed from the map by a zoomEnd handler + return; + } + this._map.on('zoomanim', this._unspiderfyZoomAnim, this); }, _unspiderfyZoomAnim: function (zoomDetails) { diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 6601a6a83..d556aced2 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -222,7 +222,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ }, _zoomEnd: function () { - + if (!this._map) { //May have been removed from the map by a zoomEnd handler + return; + } this._mergeSplitClusters(); this._zoom = this._map._zoom;