mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-30 16:14:21 +02:00
Support starting with 0 markers.
This commit is contained in:
@@ -8,7 +8,9 @@ L.MarkerCluster = L.Marker.extend({
|
|||||||
|
|
||||||
this._bounds = new L.LatLngBounds();
|
this._bounds = new L.LatLngBounds();
|
||||||
|
|
||||||
this._addChild(a);
|
if (a) {
|
||||||
|
this._addChild(a);
|
||||||
|
}
|
||||||
if (b) {
|
if (b) {
|
||||||
this._addChild(b);
|
this._addChild(b);
|
||||||
}
|
}
|
||||||
@@ -156,6 +158,10 @@ L.MarkerCluster = L.Marker.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_canAcceptPosition: function (latlng, zoom) {
|
_canAcceptPosition: function (latlng, zoom) {
|
||||||
|
if (this._childCount == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var clusterRadiusSqrd = this._group.options.maxClusterRadius * this._group.options.maxClusterRadius,
|
var clusterRadiusSqrd = this._group.options.maxClusterRadius * this._group.options.maxClusterRadius,
|
||||||
pos = this._group._map.project(this._latlng, zoom),
|
pos = this._group._map.project(this._latlng, zoom),
|
||||||
otherpos = this._group._map.project(latlng, zoom);
|
otherpos = this._group._map.project(latlng, zoom);
|
||||||
|
|||||||
@@ -307,15 +307,15 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
|||||||
|
|
||||||
return { 'clusters': clusters, 'unclustered': unclustered };
|
return { 'clusters': clusters, 'unclustered': unclustered };
|
||||||
},
|
},
|
||||||
|
|
||||||
//Clusters the given markers (with _cluster) and returns the result as a MarkerCluster
|
//Clusters the given markers (with _cluster) and returns the result as a MarkerCluster
|
||||||
_clusterToMarkerCluster: function (toCluster, zoom) {
|
_clusterToMarkerCluster: function (toCluster, zoom) {
|
||||||
var res = this._cluster(toCluster, zoom),
|
var res = this._cluster(toCluster, zoom),
|
||||||
toAdd = res.clusters.concat(res.unclustered),
|
toAdd = res.clusters.concat(res.unclustered),
|
||||||
result = new L.MarkerCluster(this, toAdd[0]),
|
result = new L.MarkerCluster(this),
|
||||||
i;
|
i;
|
||||||
|
|
||||||
for (i = toAdd.length - 1; i > 0; i--) {
|
for (i = toAdd.length - 1; i >= 0; i--) {
|
||||||
result._addChild(toAdd[i]);
|
result._addChild(toAdd[i]);
|
||||||
}
|
}
|
||||||
result._zoom = zoom;
|
result._zoom = zoom;
|
||||||
|
|||||||
Reference in New Issue
Block a user