[Pkg-javascript-commits] [leaflet-markercluster] 196/479: Add hasLayer support. Not super efficient n(log n) IIRC, but at least we have one! Refs #44

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:00:29 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 2ccd15bd434a86c6a9b3eb9182c83833b0465b1a
Author: danzel <danzel at localhost.geek.nz>
Date:   Mon Sep 3 09:53:56 2012 +1200

    Add hasLayer support. Not super efficient n(log n) IIRC, but at least we have one! Refs #44
---
 src/MarkerClusterGroup.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/MarkerClusterGroup.js b/src/MarkerClusterGroup.js
index 2bd0770..0ee8deb 100644
--- a/src/MarkerClusterGroup.js
+++ b/src/MarkerClusterGroup.js
@@ -110,6 +110,20 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
 		return this;
 	},
 
+	hasLayer: function (layer) {
+		var res = false;
+
+		this._topClusterLevel._recursively(new L.LatLngBounds([layer.getLatLng()]), 0, this._map.getMaxZoom() + 1,
+			function (cluster) {
+				for (var i = cluster._markers.length - 1; i >= 0 && !res; i--) {
+					if (cluster._markers[i] === layer) {
+						res = true;
+					}
+				}
+			}, null);
+		return res;
+	},
+
 	//Overrides FeatureGroup.onAdd
 	onAdd: function (map) {
 		L.FeatureGroup.prototype.onAdd.call(this, map);

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