Fix up crashes removing the MarkerClusterGroup from the map in a zoomstart/end handler. Crashes could come still happen depending on the order the handlers were called. Refs #36

This commit is contained in:
danzel
2012-08-27 13:55:44 +12:00
parent 863b07ea42
commit 6c4c0f1e33
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -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) {
+3 -1
View File
@@ -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;