mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-27 08:02:51 +02:00
Fix incorrectly adding parent clusters when doing a big move that changes zoom levels. Fixes #281
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
it('adds the visible marker to the map', function () {
|
||||
it('adds the visible marker to the map when zooming in', function () {
|
||||
map.setView(new L.LatLng(-37.36142550190516, 174.254150390625), 7);
|
||||
|
||||
var markers = new L.MarkerClusterGroup({
|
||||
@@ -39,7 +39,7 @@
|
||||
expect(marker._icon).to.not.be(null);
|
||||
});
|
||||
|
||||
it('adds the visible marker to the map', function () {
|
||||
it('adds the visible marker to the map when jumping around', function () {
|
||||
|
||||
var markers = new L.MarkerClusterGroup();
|
||||
var marker1 = new L.Marker([48.858280181884766, 2.2945759296417236]);
|
||||
@@ -62,4 +62,34 @@
|
||||
expect(marker2._icon).to.not.be(undefined);
|
||||
expect(marker2._icon).to.not.be(null);
|
||||
});
|
||||
|
||||
it('adds the visible markers to the map, but not parent clusters when jumping around', function () {
|
||||
|
||||
var markers = new L.MarkerClusterGroup(),
|
||||
marker1 = new L.Marker([59.9520, 30.3307]),
|
||||
marker2 = new L.Marker([59.9516, 30.3308]),
|
||||
marker3 = new L.Marker([59.9513, 30.3312]);
|
||||
|
||||
markers.addLayer(marker1);
|
||||
markers.addLayer(marker2);
|
||||
markers.addLayer(marker3);
|
||||
map.addLayer(markers);
|
||||
|
||||
//Show none of them
|
||||
map.setView([53.0676, 170.6835], 16);
|
||||
|
||||
clock.tick(1000);
|
||||
|
||||
//Zoom so that all the markers will be visible (Same as zoomToShowLayer)
|
||||
map.setView(marker1.getLatLng(), 18);
|
||||
|
||||
//Run the the animation
|
||||
clock.tick(1000);
|
||||
|
||||
//Now the markers should all be visible, and there should be no visible clusters
|
||||
expect(marker1._icon.parentNode).to.be(map._panes.markerPane);
|
||||
expect(marker2._icon.parentNode).to.be(map._panes.markerPane);
|
||||
expect(marker3._icon.parentNode).to.be(map._panes.markerPane);
|
||||
expect(map._panes.markerPane.childNodes.length).to.be(3);
|
||||
});
|
||||
});
|
||||
@@ -656,7 +656,7 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
var newBounds = this._getExpandedVisibleBounds();
|
||||
|
||||
this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, newBounds);
|
||||
this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, newBounds);
|
||||
this._topClusterLevel._recursivelyAddChildrenToMap(null, this._map._zoom, newBounds);
|
||||
|
||||
this._currentShownBounds = newBounds;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user