Add hasLayer support. Not super efficient n(log n) IIRC, but at least we have one! Refs #44

This commit is contained in:
danzel
2012-09-03 09:53:56 +12:00
parent 116a1876eb
commit 2ccd15bd43
+14
View File
@@ -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);