[Pkg-javascript-commits] [leaflet-markercluster] 126/479: Fix up removing a marker from the map while it is spiderfied. Fix up a place where markers were left with opacity 0.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:19 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 ea5428ebfb76645e2d37b69fcb885757c8463fa3
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jul 27 15:21:02 2012 +1200

    Fix up removing a marker from the map while it is spiderfied. Fix up a place where markers were left with opacity 0.
---
 src/MarkerCluster.Spiderfier.js | 18 ++++++++++++++++++
 src/MarkerClusterGroup.js       |  2 ++
 2 files changed, 20 insertions(+)

diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js
index a6256f9..60cc22b 100644
--- a/src/MarkerCluster.Spiderfier.js
+++ b/src/MarkerCluster.Spiderfier.js
@@ -256,6 +256,13 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 		setTimeout(function () {
 			for (i = childMarkers.length - 1; i >= 0; i--) {
 				m = childMarkers[i];
+
+				if (!m._spiderLeg) { //Has already been unspiderfied
+					continue;
+				}
+
+
+				m.setOpacity(1);
 				m.setZIndexOffset(0);
 
 				L.FeatureGroup.prototype.removeLayer.call(group, m);
@@ -287,5 +294,16 @@ L.MarkerClusterGroup.include({
 		if (this._spiderfied) {
 			this._spiderfied.unspiderfy();
 		}
+	},
+
+	//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) {
+			L.FeatureGroup.prototype.removeLayer.call(this, layer);
+			layer.setOpacity(1);
+			layer.setZIndexOffset(0);
+			this._map.removeLayer(layer._spiderLeg);
+			delete layer._spiderLeg;
+		}
 	}
 });
\ No newline at end of file
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 92541ed..796e0ec 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -50,6 +50,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 	removeLayer: function (layer) {
 		if (this._unspiderfy) {
 			this._unspiderfy();
+			this._unspiderfyLayer(layer);
 		}
 
 		if (!this._topClusterLevel._recursivelyRemoveLayer(layer)) {
@@ -477,6 +478,7 @@ L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? {
 
 				setTimeout(function () {
 					L.FeatureGroup.prototype.removeLayer.call(me, layer);
+					layer.setOpacity(1);
 
 					me._animationEnd();
 				}, 250);

-- 
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