A minimal example showing how to cluster GeoJSON point features. This demonstrates the basic pattern of adding a GeoJSON layer to a MarkerClusterGroup.
let geoJsonLayer = new L.GeoJSON(geoJsonData, {
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.address);
}
});
markers.addLayer(geoJsonLayer);
map.addLayer(markers);
// Automatically fit map to show all markers
map.fitBounds(markers.getBounds());
Features:
onEachFeaturefitBounds()Note: For a more complex GeoJSON example with external data loading, see the full GeoJSON example.