Reputation: 1885
Using OpenLayers 3 (a JavaScript library I'm using to display objects on a map), I have a cluster source defined this way:
(...)
var vectorSource = new ol.source.Vector();
var clusterSource = new ol.source.Cluster({
distance: 20,
source: vectorSource
});
(...)
When I build a new feature I add it to vector source this way
vectorSource.addFeature(myFeature);
My request includes an additional property which is the object they are related to. Each of these objets have their ownid
.
myFeature.linkedObject = myObject;
Where myObject.id
is the object's id
.
To say it in other words, I manage my objects and their features and let the "cluster source" manage and render clusters.
What I need now is to be able to browe through existing clusters to find which one contains the object matching some id
.
How can I get a list/array of the currently existing clusters?
Something equivalent to
var clusterSource = new ol.source.Cluster(...);
**var clusters = clusterSource.getClusters();**
which by the way doesn't exist.
Upvotes: 0
Views: 466
Reputation: 1885
Cluster sources have a getFeatures() function.
clusterSource.getFeatures();
Upvotes: 1