I am using the open layers 3 with supercluster at the moment, extending the example provided here : https://jsfiddle.net/d5gwvz2y/2/
My question is: How does one fetch all the underlying features behind a cluster if clicked? In open layers cluster implementation you could use cluster forEachFeature, or just getFeatures.
Here is a sample of the clusters working using default cluster implementation http://www.wwarn.org/surveyor/NMFI/ when a cluster is clicked, an array of features are returned, which can then be iterated through.
Best Answer
I had to make some changes to the fiddle to get it running. What I changed:
getLeaves
that you need (see 3.).getLeaves(clusterId, clusterZoom, limit = 10, offset = 0)
in your select event (as described in the supercluster project):Have a look at this working JSFiddle.
EDIT: I updated the JSFiddle to fit the question requirements of looping through the resulting child elements...
Note that you do not access features in the cluster as
ol.Feature
objects because the access is realized withsupercluster
notopenlayers
! If necessary you could access the features in openlayers by searching for certain properties to identify the feature (e.g. name property in the provided JSFiddle).