[Pkg-javascript-commits] [leaflet-markercluster] 338/479: Cludge around our hasLayer implementation to make us work with the latest Leaflet master. Fixes #159

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:49 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 47c147d9a9a5d250ef80d5a2d564fced3c5a773d
Author: danzel <danzel at localhost.geek.nz>
Date:   Mon Apr 22 09:31:10 2013 +1200

    Cludge around our hasLayer implementation to make us work with the latest Leaflet master. Fixes #159
    
    Our hasLayer returns true when we contains a marker. FeatureGroup/LayerGroup (which we inherit from) now check hasLayer when addLayer is called. At this stage our hasLayer will return true, stopping the marker from ending up on the map.
---
 src/MarkerCluster.Spiderfier.js | 2 ++
 src/MarkerCluster.js            | 8 +++++++-
 src/MarkerClusterGroup.js       | 4 ++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/MarkerCluster.Spiderfier.js b/src/MarkerCluster.Spiderfier.js
index 268bdd4..300ed87 100644
--- a/src/MarkerCluster.Spiderfier.js
+++ b/src/MarkerCluster.Spiderfier.js
@@ -152,7 +152,9 @@ L.MarkerCluster.include(!L.DomUtil.TRANSITION ? {
 			m.setZIndexOffset(1000000); //Make these appear on top of EVERYTHING
 			m.setOpacity(0);
 
+			m._noHas = true;
 			L.FeatureGroup.prototype.addLayer.call(group, m);
+			delete m._noHas;
 
 			m._setPos(thisLayerPos);
 		}
diff --git a/src/MarkerCluster.js b/src/MarkerCluster.js
index 7c493d4..bd2a7f3 100644
--- a/src/MarkerCluster.js
+++ b/src/MarkerCluster.js
@@ -132,7 +132,9 @@ L.MarkerCluster = L.Marker.extend({
 			this._backupLatlng = this._latlng;
 			this.setLatLng(startPos);
 		}
+		this._noHas = true;
 		L.FeatureGroup.prototype.addLayer.call(this._group, this);
+		delete this._noHas;
 	},
 
 	_recursivelyAnimateChildrenIn: function (bounds, center, maxZoom) {
@@ -211,7 +213,9 @@ L.MarkerCluster = L.Marker.extend({
 						nm.setOpacity(0);
 					}
 
+					nm._noHas = true;
 					L.FeatureGroup.prototype.addLayer.call(c._group, nm);
+					delete nm._noHas;
 				}
 			},
 			function (c) {
@@ -268,7 +272,9 @@ L.MarkerCluster = L.Marker.extend({
 				for (i = c._childClusters.length - 1; i >= 0; i--) {
 					m = c._childClusters[i];
 					if (!exceptBounds || !exceptBounds.contains(m._latlng)) {
-						L.FeatureGroup.prototype.removeLayer.call(c._group, m);
+						if (L.FeatureGroup.prototype.hasLayer.call(c._group, m)) {
+							L.FeatureGroup.prototype.removeLayer.call(c._group, m);
+						}
 						m.setOpacity(1);
 					}
 				}
diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index a694dd6..72a799a 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -266,6 +266,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 
 	//Returns true if the given layer is in this MarkerClusterGroup
 	hasLayer: function (layer) {
+		if (layer._noHas) {
+			return false;
+		}
+
 		if (this._needsClustering.length > 0) {
 			var anArray = this._needsClustering;
 			for (var i = anArray.length - 1; i >= 0; i--) {

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