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.

clusteradd and clusterremove events

See original GitHub issue

I am trying to execute some logic when a few markers are sucked into a cluster, and then I want to do the inverse of that, when the markers become unclustered and just separate markers again. I assumed I would be able to use clusteradd and clusterremove, since plain markers have an add and remove event, but it doesn’t seem to work. Should it be working or is there another way to do this that you can think of?

To elaborate, I have some markers that are in the center of geoJson shapes. So whenever those markers become part of a cluster, I also want the shape to get sucked into the cluster, then when unclustered, I need the geoJson shape to come back.

I’ve been poking around in the source code, trying to figure out how to do this, and I came across this:

//Don't cluster non point data
        if (!layer.getLatLng) {
            this._nonPointGroup.addLayer(layer);
            return this;
        }

Is it possible to have other layers clustered? This looks by the comment like it is keeping anything other than markers from being clustered?

Alternatively, if you could point me to which section of the code is executed when points are sucked into a cluster, and which section of code executes when the cluster is unclustered, I’d be glad to fork and do a PR with another two parameters allowing the user to pass in functions that will be called when points are sucked into a cluster, and when points are separated back out of a cluster.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rwwagner90commented, Oct 6, 2014

Leaflet provides a getCenter method, which I am using to find the center of my bounds. It’s not always exact, but it works pretty well. Knowing that center position, would it be easier to implement?

I realize solving my specific problem might take a lot of work, but how about just implementing the ability to pass in a function that would be called when a cluster is created or destroyed? Since you already know when to merge or split, couldn’t we just add an optional function param to be called when a merge or split occurs?

0reactions
bre7commented, Mar 25, 2019

Workaround to cluster Polygons (https://stackoverflow.com/a/45813585/2124535) using Turf.js’ centroid

import centroid from "@turf/centroid"

L.Polygon.addInitHook(function() {
    const auxCentroid = centroid(this.toGeoJSON())
    // FIXME Not sure why but coords are mixed up
    this._latlng = L.latLng([auxCentroid.geometry.coordinates[1], auxCentroid.geometry.coordinates[0]])
})

// Provide getLatLng and setLatLng methods for
// Leaflet.markercluster to be able to cluster polygons.
L.Polygon.include({
    getLatLng: function() {
        return this._latlng
    },
    setLatLng: function() {} // Dummy method.
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Failover Clustering system log events | Microsoft Learn
A list of Failover Clustering events in the Windows Server System log. These events can be used to troubleshoot a cluster.
Read more >
Using Cluster Events | Unreal Engine Documentation
Cluster Events are a way for you to make all the nodes in your nDisplay cluster respond to events simultaneously. You generate a...
Read more >
cluster remove-node - Product documentation - NetApp
The cluster remove-node command removes a node from a cluster. Before you can remove a node from a cluster, you must shut down...
Read more >
Configuring and managing high availability clusters Red Hat ...
Triggering scripts for cluster events ... From a node within the cluster, remove the node that was initially running nfsgroup from standby mode....
Read more >
Chapter: Clustering for the Firepower Threat Defense - Cisco
Click Add > ClusterAdd Device, and set the following parameters: ... Enter the cluster remove unit name command to remove any unit other ......
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