Get unclustered markers from leaflet when zoom changes

Viewed 72

I have 20000 markers on the map and I am using react leaflet marker cluster https://github.com/Leaflet/Leaflet.markercluster, I want to get the list of markers that are unclustered when I zoom in. I am using eachLayer method.

map.eachLayer( function(layer) {
if(layer instanceof L.Marker) {
  if(map.getBounds().contains(layer.getLatLng())) {
    features.push(layer.feature);
  }
}

But because of bulk markers, this is making my map slow, Is there any other way that can directly give me the list of unclustered markers or list of markers within bounds.

0 Answers
Related