It depends on what supercluster you are using. I assume it's the Mapbox supercluster, which lucky for you has implemented the method getLeaves() on 2017 Jan 18.
The method was implemented in particular for the purpose you are looking for ( you were not the first ask :-) ), and it was implemented with flexibility in mind as well (pagination).
The pull request also shows an in-detail explanation of the parameters of this function, I just copy them here for reference:
index.getLeaves(
clusterId, // cluster_id property of the clicked cluster
zoom, // zoom of the clicked cluster
limit, // how many points to return; 10 by default
offset); // how many points to skip for pagination; 0 by default
If you want to get all points in a cluster, either set limit
to Infinity
(yes, that's a valid value!), or use a negative value such as -1
.
If you try to retrieve large amount of point data (e.g. all 200k points in the example), you probably will have severe performance issues, plus you cannot sensibly display that information at once, either. Given your other example (showing details about a study represented by a point), you could use the additional parameters (limit, offset) to only request data as needed:
Click on the cluster to open the popup/information, but only request a chunk of the data (e.g. the first ten studies), with the first being shown right away. Then, only when the user selects one of the other studies, do another request for the next chunk of studies. Not necessarily relevant to this question, but a quick introduction to pagination never hurts for stackexchange readers ;) : It's a great way to boost UX, with better performance allowing for sleeker ways to present data.
The relevant&merged pull request (My reputation limits me to only two links, so I had to "break" the link. Just add https:// in front):
github.com/mapbox/supercluster/pull/32
And if you want the background story of the pull request as well:
github.com/mapbox/mapbox-gl-js/issues/3318