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;
}
};
Bug Report:
moveendEvent Triggered byzoomToBoundsEven Without Bounds ChangeDescription:
The
moveendevent is being fired when callingzoomToBoundseven though the map's visible bounds have not changed. This behavior is causing unnecessary updates and performance issues.Steps to Reproduce:
zoomToBoundsmethod on a cluster.moveendevent is fired even if the map's visible bounds remain the same.Expected Behavior:
The
moveendevent should only be fired when the map's visible bounds have actually changed.Suggested Fix:
Modify the
_moveEndmethod insrc/MarkerClusterGroup.jsto 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: