[Pkg-javascript-commits] [leaflet-markercluster] 127/479: Fix another silly edge case: Spiderfy 2 markers, remove one from the clusterer, the other would disappear.

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 238beee823828a5fad152c8bb4d2400d1bc45438
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jul 27 15:38:08 2012 +1200

    Fix another silly edge case: Spiderfy 2 markers, remove one from the clusterer, the other would disappear.
---
 src/MarkerCluster.Spiderfier.js | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js
index 60cc22b..60dbe06 100644
--- a/src/MarkerCluster.Spiderfier.js
+++ b/src/MarkerCluster.Spiderfier.js
@@ -254,6 +254,16 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 		}
 
 		setTimeout(function () {
+			//If we have only <= one child left then that marker will be shown on the map so don't remove it!
+			var stillThereChildCount = 0;
+			for (i = childMarkers.length - 1; i >= 0; i--) {
+				m = childMarkers[i];
+				if (m._spiderLeg) {
+					stillThereChildCount++;
+				}
+			}
+
+
 			for (i = childMarkers.length - 1; i >= 0; i--) {
 				m = childMarkers[i];
 
@@ -265,7 +275,9 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 				m.setOpacity(1);
 				m.setZIndexOffset(0);
 
-				L.FeatureGroup.prototype.removeLayer.call(group, m);
+				if (stillThereChildCount > 1) {
+					L.FeatureGroup.prototype.removeLayer.call(group, m);
+				}
 
 				map.removeLayer(m._spiderLeg);
 				delete m._spiderLeg;

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