question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Indicate if clustering/unclustering in animationend-event

See original GitHub issue

I need to perform different actions when markers are clustered/unclustered. However it seems that the animationend-event does not provide any information indicating the animation direction with it.

Are there any other approaches suggested or has this use case never occured before? If not, I’d like to propose that either an event-object will be passed to the callback or that two sub-event-types are being introduced - clusterend and unclusterend - that are getting fired together with animationend respectively.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
Azmisovcommented, Feb 1, 2018

I would like to open/close a popup when the a marker is clustered / unclustered. The popup is not attached to the marker directly… it is just associated with it. I have cached a value popup_marker and need to detect whether this marker has just been clustered / unclustered to toggle a popup.

I found out the unclustering always calls the iconCreateFunction (correct me if I’m wrong). So I added the open popup trigger to that. But I still need a way to detect when the marker gets clustered again. Any suggestions?

0reactions
Azmisovcommented, Mar 18, 2019

Yes, I believe I did. You can do something like this:

iconCreateFunction: function(c){
    if (!c.is_spiderfied){
        for (const n of c.getAllChildMarkers()){
            markerClustered(n);
            // or you can do something more specific like this:
            if (n == active_popup_marker)
                closeActivePopup();
        }
    }
}

There is no event I know to detect a marker being clustered directly. However, the iconCreateFunction gets called when it creates the meta “clustered” icon; the children of the meta icon are all the markers that were clustered.

The c.is_spiderfied flag I set manually based on the spiderfied and unspiderfied events. If you aren’t using the spiderfy feature, you can remove that part.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet and MarkerCluster - don't perform clustering when ...
Currenrly, i'm forced to listen for every "animationend" event (when any change happens to the clusters controlled by MarkerCluster anywhere on ...
Read more >
Element: animationend event - Web APIs | MDN
The animationend event is fired when a CSS Animation has completed. If the animation aborts before reaching completion, such as if the ...
Read more >
How to determine if a cluster is at its maxZoom level?
Ok, just did a quick test and was able to confirm that the animationend event will do the trick: // markers is the...
Read more >
Leaflet.markercluster - Shenchen Liu's website
Provides Beautiful Animated Marker Clustering functionality for Leaflet, ... when creating the L.Polygon(points, options) to show the bounds of a cluster.
Read more >
leaflet-cluster · master · MAKB / MapKB · GitLab - USGS.gov
The following methods can be used with clusters (not the group). They are typically used for event handling. Getting the bounds of a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found