A modern study React wrapper of marker cluster for react-leaflet
React wrapper of Leaflet.markercluster for react-leaflet based in react-leaflet-markercluster
dist/
└── index.min.js
yarn add leaflet leaflet.markercluster react-leaflet
yarn add react-leaflet-muster@ˆ1.0.3
yarn add react-leaflet-muster@^2.0.1
<MarkerMuster>
<Marker position={[-21.210309, -47.647063]}/>
<Marker position={[-21.210309, -47.647063]}/>
</MarkerMuster>
import "leaflet/dist/leaflet.css";
import { MarkerMuster } from "react-leaflet-muster";
import { MapContainer, TileLayer, Marker } from "react-leaflet";
function Map() {
return(
<MapContainer
zoom={14}
center={[-22.2108112, -49.6771926]}
>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
/>
<MarkerMuster>
<Marker position={[-21.210309, -47.647063]}/>
<Marker position={[-21.210309, -47.647063]}/>
</MarkerMuster>
</MapContainer>
)
}
You can see the properties in Leaflet.markercluster All Options
<MarkerMuster
showCoverageOnHover={false}
zoomToBoundsOnClick={false}
>
<Marker position={[-21.210309, -47.647063]}/>
<Marker position={[-21.210309, -47.647063]}/>
</MarkerMuster>
<MarkerMuster
onCLick={e => console.log(e)}
onMouseOver={e => console.log(e)}
>
<Marker position={[-21.210309, -47.647063]}/>
<Marker position={[-21.210309, -47.647063]}/>
</MarkerMuster>
All credits and rights to Yevhen Uzhva of react-leaflet-markercluster