0

Some used them together?

Maybe there is a component for the PruneCluster?

It will be great to see some examples/tutorials....

2 Answers 2

0

Download the prunecluster from npm.

Copy it to your local js directory.

add the line

exports.PruneCluster = PruneCluster;

Then start using it :

var P = require('../Lib/PruneCluster');
this.clusterGroup = new P.PruneClusterForLeaflet();

The author don't have plans to make it React compatible. https://github.com/SINTEF-9012/PruneCluster/issues/102

EDIT:

PruneCluster should use as it is in the official documentation. The problem is, leaflet is mounted as react component.

The better answer is to expose leaflet map object from the react component.

This way you can use prunecluster as it is.

The example above is bad, see this Example which shows how to access leaflet map, which is half the solution. From there, just use Prunecluster as normal JS and create layers that you then add to leaflet map object that you got from my example.

2
  • how would you use this in a react component? You should probably elaborate more. Commented Sep 21, 2020 at 22:11
  • Writing a working example isn't a quick task, however I updated the answer with a codepen example.
    – Aus
    Commented Sep 23, 2020 at 10:27
-1

I would suggest trying this React component https://yuzhva.github.io/react-leaflet-markercluster

Those React component have similar functionality with PruneCluster.

2
  • i know this is an old comment, but this library has not been kept up to date and does not work with react-leaflet.
    – catbadger
    Commented Sep 30, 2019 at 4:45
  • Does not work the same, prune cluster is much faster
    – Sahin
    Commented Jun 30, 2022 at 6:57

Not the answer you're looking for? Browse other questions tagged or ask your own question.