[Pkg-javascript-commits] [leaflet-markercluster] 346/479: Fix clearLayers with spiderfied markers. Refs #162

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit 890406abd63e05e6ac6720264816b6ab0fc6a8da
Author: danzel <danzel at localhost.geek.nz>
Date:   Wed Apr 24 10:44:46 2013 +1200

    Fix clearLayers with spiderfied markers. Refs #162
---
 src/MarkerCluster.Spiderfier.js | 50 ++++++++++++++++++++++++++---------------
 src/MarkerClusterGroup.js       |  4 ++--
 2 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js
index 300ed87..7005192 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 72a799a..60c48d8 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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git



More information about the Pkg-javascript-commits mailing list