[Pkg-javascript-commits] [leaflet-markercluster] 123/479: unspiderfy before adding/removing a layer

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 4e4cba28cb2b820837225cb050aa137dad3326d2
Author: danzel <danzel at localhost.geek.nz>
Date:   Fri Jul 27 14:01:30 2012 +1200

    unspiderfy before adding/removing a layer
---
 src/MarkerClusterGroup.js | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 52a51b6..5fb9852 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -36,6 +36,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 		//If we have already clustered we'll need to add this one to a cluster
 
+		if (this._unspiderfy) {
+			this._unspiderfy();
+		}
+
 		var newCluster = this._topClusterLevel._recursivelyAddLayer(layer, this._topClusterLevel._zoom - 1);
 
 		this._animationAddLayer(layer, newCluster);
@@ -44,7 +48,15 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 	},
 
 	removeLayer: function (layer) {
-		this._topClusterLevel._recursivelyRemoveLayer(layer);
+		if (this._unspiderfy) {
+			this._unspiderfy();
+		}
+
+		if (!this._topClusterLevel._recursivelyRemoveLayer(layer)) {
+			//If this happens you are doing something bad
+			//If you've moved a marker that is in the cluster then that would be why
+			//console.log('failed to remove');
+		}
 
 		return this;
 	},

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