react-leaflet-markercluster icon indicating copy to clipboard operation
react-leaflet-markercluster copied to clipboard

Support for MarkerCluster sub-plugins

Open elvir92 opened this issue 6 years ago • 5 comments

Hi Is there any way to inject sub-plugins like Freezable

elvir92 avatar Aug 06 '18 02:08 elvir92

@elvir92 Em.. - nope, currently there is no way to do that, also I don't remember any example.

Need to think about implementation.

yuzhva avatar Aug 06 '18 08:08 yuzhva

Can you give me an advice, i would like to do it, but i don't know how to or where to start.

elvir92 avatar Aug 06 '18 12:08 elvir92

According to Freezable doc. you need to use that lib directly with Leaflet element (wich was created by Leaflet.js):

var mcg = L.markerClusterGroup(options);

mcg.freezeAtZoom(15);
mcg.freezeAtZoom("maxKeepSpiderfy");
mcg.freezeAtZoom("max");

mcg - that is LeafleElelemnt. You can try to get leaflet element of MarkerCluser by ref:

require('leaflet.markercluster.freezable');

...

handleMarkerClusterGroupLeafletElement(leafletElement) {
  this.leafletElement = leafletElement;

  // NOTE: here you can do whatever you need with leafletElement
  this.leafletElement.freezeAtZoom(15);
}

...

render() {
  return (
    <MarkerClusterGroup ref={handleMarkerClusterGroupLeafletElement}>
      <Marker position={[49.8397, 24.0297]} />
      <Marker position={[52.2297, 21.0122]} />
      <Marker position={[51.5074, -0.0901]} />
    </MarkerClusterGroup>
  )
}

yuzhva avatar Aug 06 '18 13:08 yuzhva

FYI, the placementStrategies sub-plugin can just be imported and it works. So it depends on the sub-plugins.

wmertens avatar Mar 27 '19 16:03 wmertens

Hello, what about the clustering and clustering dynamically/programmatically?. In react at least, I have to add FeatureGroup or MarkerClusterGroup accordingly If I must to show markers clustered or unclustered. Is there a chance to do this programmatically?

dpadula avatar Jan 21 '21 13:01 dpadula