i need to iterate over all clusters that are currently present in markercluster using leaflet. there's a method called markercluster.getClusters() in googlemaps to do this job.

is there something similar in leaflet too?

  • pls help..it's urgent!!
    – Akshay
    Jan 7, 2015 at 16:46

2 Answers 2


To expand on @toms answer

map.eachLayer(function(layer){     //iterate over map rather than clusters
 if (layer.getChildCount){         // if layer is markerCluster
  console.log(layer._childCount);  // return count of points within each cluster

if you mean iterate over all the individual points in an L.markerClusterGroup(), you can use something like this to access the individual layers


If you want to get at the points/layers in an individual cluster, you can use getAllChildMarkers()

markers.on('clusterclick', function (a) {
    console.log('cluster ' + a.layer.getAllChildMarkers().length);

additional documentation here

  • hey thanks for your early reply..i want to iterate over clusters not over markers in the markercluster.eg: if say suppose currently i can see 2 clusters on the screen, then i want to retive those two individual clusters. refer getClusters() method in google maps
    – Akshay
    Jan 8, 2015 at 5:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.