[Pkg-javascript-commits] [leaflet-markercluster] 282/479: Unset layer.__parent in removeLayers as well as removeLayer. Refs #44

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:39 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 ef2a51235eea7b233992c45c6cf87d888ebd3993
Author: danzel <danzel at localhost.geek.nz>
Date:   Thu Nov 1 09:45:04 2012 +1300

    Unset layer.__parent in removeLayers as well as removeLayer. Refs #44
---
 src/MarkerClusterGroup.js | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 17c9e75..850a937 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -110,8 +110,6 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			layer.setOpacity(1);
 		}
 
-		delete layer.__parent;
-
 		return this;
 	},
 
@@ -124,6 +122,11 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 		for (var i = 0, l = layersArray.length; i < l; i++) {
 			var m = layersArray[i];
+
+			if (this.hasLayer(m)) {
+				continue;
+			}
+
 			this._addLayer(m, this._maxZoom);
 
 			//If we just made a cluster of size 2 then we need to remove the other marker from the map (if it is) or we never will
@@ -389,6 +392,8 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 			cluster = cluster.__parent;
 		}
+
+		delete marker.__parent;
 	},
 
 	//Overrides FeatureGroup._propagateEvent
@@ -547,10 +552,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 			//Try find a marker close by to form a new cluster with
 			closest = gridUnclustered[zoom].getNearObject(markerPoint);
 			if (closest) {
-				if (closest.__parent) {
+				var parent = closest.__parent;
+				if (parent) {
 					this._removeLayer(closest, false);
 				}
-				var parent = closest.__parent;
 
 				//Create new cluster with these 2 in it
 

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