迭代集群源中的 OpenLayers 3 集群

Iterating through OpenLayers 3 clusters in cluster source

使用 OpenLayers 3(我用来在地图上显示对象的 JavaScript 库),我有一个这样定义的集群源:

(...)
var vectorSource = new ol.source.Vector();
var clusterSource = new ol.source.Cluster({
                distance: 20,
                source: vectorSource
            });
(...)

当我构建一个新特征时,我会以这种方式将它添加到矢量源中

vectorSource.addFeature(myFeature);

我的请求包括一个额外的 属性,这是它们相关的对象。这些对象中的每一个都有自己的id.

myFeature.linkedObject = myObject;

其中 myObject.id 是对象的 id.

换句话说,我管理我的对象及其特征,让 "cluster source" 管理和渲染集群。

我现在需要的是能够浏览现有的集群以找到哪个包含与某些 id.

匹配的对象

如何获取当前存在的集群的 list/array?

相当于

var clusterSource = new ol.source.Cluster(...);
**var clusters = clusterSource.getClusters();**

顺便说一下,这不存在。

集群源具有 getFeatures() 函数。

clusterSource.getFeatures();