-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Description
Bug Report: moveend
Event Triggered by zoomToBounds
Even Without Bounds Change
Description:
The moveend
event is being fired when calling zoomToBounds
even though the map's visible bounds have not changed. This behavior is causing unnecessary updates and performance issues.
Steps to Reproduce:
- Create a map with clusters using Leaflet.markercluster.
- Call the
zoomToBounds
method on a cluster. - Observe that the
moveend
event is fired even if the map's visible bounds remain the same.
Expected Behavior:
The moveend
event should only be fired when the map's visible bounds have actually changed.
Suggested Fix:
Modify the _moveEnd
method in src/MarkerClusterGroup.js
to check if the map's visible bounds have actually changed before performing updates.
JS Fiddle:
Please look into this https://jsfiddle.net/4r8k9hLj/14/.
Example Code:
_moveEnd: function () {
if (this._inZoomAnimation) {
return;
}
var newBounds = this._getExpandedVisibleBounds();
// Check if the map has visibly moved
if (!this._currentShownBounds.equals(newBounds)) {
this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, Math.floor(this._map.getMinZoom()), this._zoom, newBounds);
this._topClusterLevel._recursivelyAddChildrenToMap(null, Math.round(this._map._zoom), newBounds);
this._currentShownBounds = newBounds;
}
};
Metadata
Metadata
Assignees
Labels
No labels