This example demonstrates how to use MarkerClusterGroup with GeoJSON data. The plugin can cluster any Leaflet layer, including GeoJSON features, markers, polylines, and polygons.
let geojson = new L.GeoJSON(data, {
onEachFeature: function(feature, layer) {
layer.bindPopup(feature.properties.name);
}
});
let markers = new L.MarkerClusterGroup();
markers.addLayer(geojson);
map.addLayer(markers);
Features:
Tip: Hover over clusters to see their coverage area, and click to zoom to the cluster bounds.