Coder Social home page Coder Social logo

Comments (5)

danzel avatar danzel commented on September 13, 2024

Looks like zooming out one level at a time before the animation finishes break it. Zooming in by itself is fine.

from leaflet.markercluster.

danzel avatar danzel commented on September 13, 2024

No I lie. Happens on zoom ins too, just less obvious.
Put the mouse in the corner of the zoom and do it.

from leaflet.markercluster.

danzel avatar danzel commented on September 13, 2024

Have fiddled with this all day. It's a pain to fix!

The issue is:

User hits zoom out.
[zoomstart]
[zoomanim]
Map does zoom out animation.
[zoomend]
Clusterer starts moving all markers towards their cluster position, queues up an event to remove them and add the cluster when the animation is done (250ms)

Then the silly user immediately hits zoom out before that timeout has fired, so:
[zoomstart]
[zoomanim]
Map does zoom out animation.
(In the middle of the animation the timeout fires and puts the markers on the map in the wrong place. I think)
[zoom end]
Clusterer does the same as above and fixes everything up.

My attempt to fix it was to remember the timeout when we set it up and if zoomstart fires before the timeout triggers then to call the timeout function then and clear the timeout. This should mean that the points are on the map as they should be, but it doesn't really work as expected as the new clusters get added at the location they should be at after the zoom animation rather than the location before and then .

One other problem is that when the user starts the second zoom out, the markers may be part way through their animation to move to their cluster location, so their location isn't known.

from leaflet.markercluster.

danzel avatar danzel commented on September 13, 2024

Okay, managed to get it to go!
The secret was to add the new (for the new zoom level) clusters to the map immediately after a zoom, but only make them visible when we want.
This means they are always correctly positioned (as leaflet looks after it for us) so the zoom animations don't break! yay!

from leaflet.markercluster.

mourner avatar mourner commented on September 13, 2024

Masterful fix David, awesome :)

from leaflet.markercluster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.