react-leaflet-markercluster
react-leaflet-markercluster copied to clipboard
Support for MarkerCluster sub-plugins
Hi Is there any way to inject sub-plugins like Freezable
@elvir92 Em.. - nope, currently there is no way to do that, also I don't remember any example.
Need to think about implementation.
Can you give me an advice, i would like to do it, but i don't know how to or where to start.
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>
)
}
FYI, the placementStrategies sub-plugin can just be imported and it works. So it depends on the sub-plugins.
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?