I am trying to add clusters in my leaflet map. I use overlayMaps
which helps to choose one of the active layers, and in that case I want my marker to be a cluster. But it is not clustering. Again when I am trying with making any overlayMaps
variable and put all the data its working the marker are cluster.
I want to show cluster in the map when the layer is active.
Plugin used: https://github.com/Leaflet/Leaflet.markercluster
var cluster = L.markerClusterGroup();
var geo = L.geoJSON(dataview, {
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.tags.name);
},
});
geo.addTo(cluster);
var overlayMaps = {
tourism: tourism,
hospital: geo,
};
//add the layer control option
L.control.layers(baseMaps, overlayMaps).addTo(map);