mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 08:02:41 +02:00
Respect disableClusteringAtZoom when adding individual layers
This commit is contained in:
+23
-14
@@ -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,21 +128,24 @@ 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))) {
|
||||
|
||||
//Add to ourself instead
|
||||
var layerPos = map.project(layer.getLatLng(), zoom + 1),
|
||||
sqDist = this._group._sqDist;
|
||||
//If we are allowed to cluster at our childs level
|
||||
if (zoom + 1 !== group.options.disableClusteringAtZoom) {
|
||||
|
||||
//var distanceGrid = new L.DistanceGrid(maxClusterRadius);
|
||||
for (i = this._markers.length - 1; i >= 0; i--) {
|
||||
var m = this._markers[i];
|
||||
if (sqDist(layerPos, map.project(m.getLatLng(), zoom + 1)) < (maxClusterRadius * maxClusterRadius)) {
|
||||
result = m;
|
||||
this._markers.splice(i, 1);
|
||||
this._childCount--;
|
||||
break;
|
||||
//Add to ourself instead
|
||||
var layerPos = map.project(layer.getLatLng(), zoom + 1),
|
||||
sqDist = this._group._sqDist;
|
||||
|
||||
//var distanceGrid = new L.DistanceGrid(maxClusterRadius);
|
||||
for (i = this._markers.length - 1; i >= 0; i--) {
|
||||
var m = this._markers[i];
|
||||
if (sqDist(layerPos, map.project(m.getLatLng(), zoom + 1)) < (maxClusterRadius * maxClusterRadius)) {
|
||||
result = m;
|
||||
this._markers.splice(i, 1);
|
||||
this._childCount--;
|
||||
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