diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js index 300ed8745..70051929e 100644 --- a/src/MarkerCluster.Spiderfier.js +++ b/src/MarkerCluster.Spiderfier.js @@ -83,6 +83,31 @@ L.MarkerCluster.include({ legLength += this._2PI * lengthFactor / angle; } return res; + }, + + _noanimationUnspiderfy: function () { + var group = this._group, + map = group._map, + childMarkers = this.getAllChildMarkers(), + m, i; + + this.setOpacity(1); + for (i = childMarkers.length - 1; i >= 0; i--) { + m = childMarkers[i]; + + L.FeatureGroup.prototype.removeLayer.call(group, m); + + if (m._preSpiderfyLatlng) { + m.setLatLng(m._preSpiderfyLatlng); + delete m._preSpiderfyLatlng; + } + m.setZIndexOffset(0); + + if (m._spiderLeg) { + map.removeLayer(m._spiderLeg); + delete m._spiderLeg; + } + } } }); @@ -113,24 +138,7 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? { }, _animationUnspiderfy: function () { - var group = this._group, - map = group._map, - childMarkers = this.getAllChildMarkers(), - m, i; - - this.setOpacity(1); - for (i = childMarkers.length - 1; i >= 0; i--) { - m = childMarkers[i]; - - L.FeatureGroup.prototype.removeLayer.call(group, m); - - m.setLatLng(m._preSpiderfyLatlng); - delete m._preSpiderfyLatlng; - m.setZIndexOffset(0); - - map.removeLayer(m._spiderLeg); - delete m._spiderLeg; - } + this._noanimationUnspiderfy(); } } : { //Animated versions here @@ -378,6 +386,12 @@ L.MarkerClusterGroup.include({ } }, + _noanimationUnspiderfy: function () { + if (this._spiderfied) { + this._spiderfied._noanimationUnspiderfy(); + } + }, + //If the given layer is currently being spiderfied then we unspiderfy it so it isn't on the map anymore etc _unspiderfyLayer: function (layer) { if (layer._spiderLeg) { diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js index 72a799a98..60c48d8ca 100644 --- a/src/MarkerClusterGroup.js +++ b/src/MarkerClusterGroup.js @@ -214,8 +214,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({ delete this._gridUnclustered; } - if (this._unspiderfy) { - this._unspiderfy(); + if (this._noanimationUnspiderfy) { + this._noanimationUnspiderfy(); } //Remove all the visible layers