mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Add eachChildLayer, an eachLayer implementation. We cannot override eachLayer as we have different behaviour. Doing so makes us add all makers to the map always which is dumb :(
Fixes #102
This commit is contained in:
@@ -107,6 +107,7 @@ If you are removing a lot of markers it will almost definitely be better to call
|
||||
|
||||
### Other Methods
|
||||
````
|
||||
eachChildLayer(method, context): Provides an eachLayer implementation. (eachLayer operates on each visible layer, this method runs on all layers added to the MarkerClusterGroup)
|
||||
hasLayer(layer): Returns true if the given layer (marker) is in the MarkerClusterGroup
|
||||
zoomToShowLayer(layer, callback): Zooms to show the given marker (spidifying if required), calls the callback when the marker is visible on the map
|
||||
addLayers(layerArray): Adds the markers in the given array from the MarkerClusterGroup in an efficent bulk method.
|
||||
|
||||
@@ -230,6 +230,20 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
return bounds;
|
||||
},
|
||||
|
||||
//Don't override LayerGroup.eachLayer, but provide the same functionality for external users
|
||||
eachChildLayer: function (method, context) {
|
||||
var markers = this._needsClustering.slice(),
|
||||
i;
|
||||
|
||||
if (this._topClusterLevel) {
|
||||
this._topClusterLevel.getAllChildMarkers(markers);
|
||||
}
|
||||
|
||||
for (i = markers.length - 1; i >= 0; i--) {
|
||||
method.call(context, markers[i]);
|
||||
}
|
||||
},
|
||||
|
||||
//Returns true if the given layer is in this MarkerClusterGroup
|
||||
hasLayer: function (layer) {
|
||||
if (this._needsClustering.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user