[Pkg-javascript-commits] [leaflet-markercluster] 36/479: Working on fixing adding/removing. This fixes the case where you have 2 markers clustered, then zoom out twice, then delete one.

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:06 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 12e6eb0133ebb78f84988a8256e876355dc34a33
Author: danzel <danzel at localhost.geek.nz>
Date:   Wed Jul 18 13:33:45 2012 +1200

    Working on fixing adding/removing. This fixes the case where you have 2 markers clustered, then zoom out twice, then delete one.
---
 src/MarkerClusterGroup.js | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 98041da..3cef276 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -222,14 +222,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		//Remove the marker
 		L.FeatureGroup.prototype.removeLayer.call(this, layer);
 
-		if (i !== -1) //Is unclustered at the current zoom level
-		{
+		if (i !== -1) { //Is unclustered at the current zoom level
 			current.unclustered.splice(i, 1);
 			
 			killParents = true; //Need to rebuild parents as they may be clusters just because this marker makes them one
-		}
-		else //it is a child of a cluster
-		{
+		} else { //it is a child of a cluster
 			//Find the cluster
 			for (i = current.clusters.length - 1; i >= 0; i--) {
 				var c = current.clusters[i];
@@ -238,8 +235,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 					if (c._childCount == 1) {
 						//Remove cluster and add individual marker
 						L.FeatureGroup.prototype.removeLayer.call(this, c);
-						L.FeatureGroup.prototype.addLayer.call(this, c._markers[0]);
-						current.unclustered.push(c._markers[0]);
+						var marker = c.getAllChildMarkers()[0];
+						L.FeatureGroup.prototype.addLayer.call(this, marker);
+						current.unclustered.push(marker);
+						current.clusters.splice(i, 1);
 						killParents = true; //Need to rebuild parents as they could have references to this cluster
 					}
 					break;

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