mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Test if a marker is already in the cluster before adding it. You can skip this (for performance) by setting the skipDuplicateAddTesting option. Testing is only done after the MarkerClusterGroup has been added to the map, so any duplicates added before then will not be caught.
This commit is contained in:
@@ -49,6 +49,7 @@ Check out the [custom example](http://danzel.github.com/Leaflet.markercluster/ex
|
||||
### Other Options
|
||||
disableClusteringAtZoom: If set, at this zoom level and below markers will not be clustered. This defaults to disabled. [See Example](http://danzel.github.com/Leaflet.markercluster/example/marker-clustering-realworld-maxzoom.388.html)
|
||||
singleMarkerMode: If set to true, overrides the icon for all added markers to make them appear as a 1 size cluster
|
||||
skipDuplicateAddTesting: By default we check if a marker already exists in the cluster when addLayer is called. To disable this behaviour set this to true. You must only do this if you know you will not try add markers that are already in the cluster. Provides a slight performance boost to addLayer when called after the MarkerClusterGroup is on the map.
|
||||
|
||||
### Events
|
||||
If you register for click, mouseover, etc events just related to Markers in the cluster.
|
||||
|
||||
@@ -14,7 +14,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
zoomToBoundsOnClick: true,
|
||||
singleMarkerMode: false,
|
||||
|
||||
disableClusteringAtZoom: null
|
||||
disableClusteringAtZoom: null,
|
||||
|
||||
skipDuplicateAddTesting: false
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
@@ -33,8 +35,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
|
||||
addLayer: function (layer) {
|
||||
|
||||
if (layer instanceof L.LayerGroup)
|
||||
{
|
||||
if (layer instanceof L.LayerGroup) {
|
||||
for (var i in layer._layers) {
|
||||
if (layer._layers.hasOwnProperty(i)) {
|
||||
this.addLayer(layer._layers[i]);
|
||||
@@ -59,6 +60,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
return this;
|
||||
}
|
||||
|
||||
if (!this.options.skipDuplicateAddTesting && this.hasLayer(layer)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
//If we have already clustered we'll need to add this one to a cluster
|
||||
|
||||
if (this._unspiderfy) {
|
||||
|
||||
Reference in New Issue
Block a user