mirror of
https://github.com/stylersnico/librenms.git
synced 2026-08-03 08:01:38 +02:00
Respect disableClusteringAtZoom when adding individual layers
This commit is contained in:
+12
-3
@@ -107,8 +107,9 @@ L.MarkerCluster = L.Marker.extend({
|
||||
// false: wasn't able to put this marker in
|
||||
// a MarkerCluster: the visible parent of the marker
|
||||
_recursivelyAddLayer: function (layer, zoom) {
|
||||
var map = this._group._map,
|
||||
maxClusterRadius = this._group.options.maxClusterRadius,
|
||||
var group = this._group,
|
||||
map = group._map,
|
||||
maxClusterRadius = group.options.maxClusterRadius,
|
||||
result = false,
|
||||
i;
|
||||
|
||||
@@ -127,6 +128,9 @@ L.MarkerCluster = L.Marker.extend({
|
||||
//Couldn't add it to a child, but it should be part of us (this._zoom -> we are the root node)
|
||||
if (!result && (this._canAcceptPosition(layer.getLatLng(), zoom) || ('_zoom' in this))) {
|
||||
|
||||
//If we are allowed to cluster at our childs level
|
||||
if (zoom + 1 !== group.options.disableClusteringAtZoom) {
|
||||
|
||||
//Add to ourself instead
|
||||
var layerPos = map.project(layer.getLatLng(), zoom + 1),
|
||||
sqDist = this._group._sqDist;
|
||||
@@ -141,7 +145,7 @@ L.MarkerCluster = L.Marker.extend({
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//result = distanceGrid.getNearObject(map.project(layer.getLatLng(), zoom + 1));
|
||||
|
||||
if (result) {
|
||||
@@ -158,6 +162,11 @@ L.MarkerCluster = L.Marker.extend({
|
||||
maxZoom = map.getMaxZoom(),
|
||||
newResult,
|
||||
finalResult = (zoom === wantedZoom) ? result : true;
|
||||
|
||||
if (group.options.disableClusteringAtZoom) {
|
||||
maxZoom = group.options.disableClusteringAtZoom - 2;
|
||||
}
|
||||
|
||||
while (zoom < maxZoom) {
|
||||
zoom++;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user