mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 00:24:21 +02:00
Update build
This commit is contained in:
Vendored
+71
-62
@@ -32,6 +32,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
//Increase to increase the distance away that spiderfied markers appear from the center
|
||||
spiderfyDistanceMultiplier: 1,
|
||||
|
||||
//When bulk adding layers, runs chunks at a time. Means addLayers may not add all the layers in the call, others will be loaded during setTimeouts
|
||||
chunkedLoading: false,
|
||||
chunkSize: 500,
|
||||
|
||||
//Options to pass to the L.Polygon constructor
|
||||
polygonOptions: {}
|
||||
},
|
||||
@@ -158,52 +162,76 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
|
||||
//Takes an array of markers and adds them in bulk
|
||||
addLayers: function (layersArray) {
|
||||
var i, l, m,
|
||||
onMap = this._map,
|
||||
fg = this._featureGroup,
|
||||
npg = this._nonPointGroup;
|
||||
var fg = this._featureGroup,
|
||||
npg = this._nonPointGroup,
|
||||
chunkSize = this.options.chunkSize,
|
||||
newMarkers, i, l, m;
|
||||
|
||||
for (i = 0, l = layersArray.length; i < l; i++) {
|
||||
m = layersArray[i];
|
||||
if (this._map) {
|
||||
var start = 0;
|
||||
var end = this.options.chunkedLoading && chunkSize < layersArray.length ? chunkSize : layersArray.length;
|
||||
var process = L.bind(function () {
|
||||
for (i = start; i < end; i++) {
|
||||
m = layersArray[i];
|
||||
|
||||
//Not point data, can't be clustered
|
||||
if (!m.getLatLng) {
|
||||
npg.addLayer(m);
|
||||
continue;
|
||||
}
|
||||
//Not point data, can't be clustered
|
||||
if (!m.getLatLng) {
|
||||
npg.addLayer(m);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.hasLayer(m)) {
|
||||
continue;
|
||||
}
|
||||
if (this.hasLayer(m)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!onMap) {
|
||||
this._needsClustering.push(m);
|
||||
continue;
|
||||
}
|
||||
this._addLayer(m, this._maxZoom);
|
||||
|
||||
this._addLayer(m, this._maxZoom);
|
||||
|
||||
//If we just made a cluster of size 2 then we need to remove the other marker from the map (if it is) or we never will
|
||||
if (m.__parent) {
|
||||
if (m.__parent.getChildCount() === 2) {
|
||||
var markers = m.__parent.getAllChildMarkers(),
|
||||
otherMarker = markers[0] === m ? markers[1] : markers[0];
|
||||
fg.removeLayer(otherMarker);
|
||||
//If we just made a cluster of size 2 then we need to remove the other marker from the map (if it is) or we never will
|
||||
if (m.__parent) {
|
||||
if (m.__parent.getChildCount() === 2) {
|
||||
var markers = m.__parent.getAllChildMarkers(),
|
||||
otherMarker = markers[0] === m ? markers[1] : markers[0];
|
||||
fg.removeLayer(otherMarker);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (onMap) {
|
||||
//Update the icons of all those visible clusters that were affected
|
||||
fg.eachLayer(function (c) {
|
||||
if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
|
||||
c._updateIcon();
|
||||
if (end === layersArray.length) {
|
||||
//Update the icons of all those visible clusters that were affected
|
||||
this._featureGroup.eachLayer(function (c) {
|
||||
if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) {
|
||||
c._updateIcon();
|
||||
}
|
||||
});
|
||||
|
||||
this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
|
||||
} else {
|
||||
start = end;
|
||||
end = Math.min(end + chunkSize, layersArray.length);
|
||||
setTimeout(process, 0);
|
||||
}
|
||||
});
|
||||
}, this);
|
||||
|
||||
this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
|
||||
process();
|
||||
} else {
|
||||
newMarkers = [];
|
||||
for (i = 0, l = layersArray.length; i < l; i++) {
|
||||
m = layersArray[i];
|
||||
|
||||
//Not point data, can't be clustered
|
||||
if (!m.getLatLng) {
|
||||
npg.addLayer(m);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.hasLayer(m)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newMarkers.push(m);
|
||||
}
|
||||
this._needsClustering = this._needsClustering.concat(newMarkers);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
@@ -419,23 +447,9 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
}
|
||||
this._needsRemoving = [];
|
||||
|
||||
for (i = 0, l = this._needsClustering.length; i < l; i++) {
|
||||
layer = this._needsClustering[i];
|
||||
|
||||
//If the layer doesn't have a getLatLng then we can't cluster it, so add it to our child featureGroup
|
||||
if (!layer.getLatLng) {
|
||||
this._featureGroup.addLayer(layer);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (layer.__parent) {
|
||||
continue;
|
||||
}
|
||||
this._addLayer(layer, this._maxZoom);
|
||||
}
|
||||
this._needsClustering = [];
|
||||
|
||||
//Remember the current zoom level and bounds
|
||||
this._zoom = this._map.getZoom();
|
||||
this._currentShownBounds = this._getExpandedVisibleBounds();
|
||||
|
||||
this._map.on('zoomend', this._zoomEnd, this);
|
||||
this._map.on('moveend', this._moveEnd, this);
|
||||
@@ -446,15 +460,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
|
||||
this._bindEvents();
|
||||
|
||||
|
||||
//Actually add our markers to the map:
|
||||
|
||||
//Remember the current zoom level and bounds
|
||||
this._zoom = this._map.getZoom();
|
||||
this._currentShownBounds = this._getExpandedVisibleBounds();
|
||||
|
||||
//Make things appear on the map
|
||||
this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds);
|
||||
l = this._needsClustering;
|
||||
this._needsClustering = [];
|
||||
this.addLayers(l);
|
||||
},
|
||||
|
||||
//Overrides FeatureGroup.onRemove
|
||||
@@ -632,7 +641,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
e.layer.zoomToBounds();
|
||||
}
|
||||
|
||||
// Focus the map again for keyboard users.
|
||||
// Focus the map again for keyboard users.
|
||||
if (e.originalEvent && e.originalEvent.keyCode === 13) {
|
||||
map._container.focus();
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user