Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue: moveend Event Triggered by zoomToBounds Even Without Bounds Change #1112

Open
Karan9615-off opened this issue Jan 7, 2025 · 4 comments

Comments

@Karan9615-off
Copy link

Karan9615-off commented Jan 7, 2025

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:

  1. Create a map with clusters using Leaflet.markercluster.
  2. Call the zoomToBounds method on a cluster.
  3. 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;
    }
};
@Karan9615-off
Copy link
Author

Additional Information

@Karan9615-off
Copy link
Author

I have already made changes, please confirm when i can create a PR.

@IvanSanchez
Copy link
Member

Can you please provide a minimal reproducible example and/or a stack trace? I'm not seeing any fire('moveend') calls in the MarkerCluster code.

@Karan9615-off
Copy link
Author

Karan9615-off commented Jan 7, 2025

@IvanSanchez
Please look into this https://jsfiddle.net/4r8k9hLj/14/.

@Karan9615-off Karan9615-off changed the title Issue: moveend Event Firing During Spiderfying (Bounds not changed) Issue: moveend Event Triggered by zoomToBounds Even Without Bounds Change Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants