使用openlayers 3(我用来在地图上显示对象的javascript库),我有一个群集源以这种方式定义:
(...)
var vectorSource = new ol.source.Vector();
var clusterSource = new ol.source.Cluster({
distance: 20,
source: vectorSource
});
(...)
当我构建一个新功能时,我将其添加到矢量源
vectorSource.addFeature(myFeature);
我的请求包括一个附加属性,该属性是与其相关的对象。这些objets都有自己的id
。
myFeature.linkedObject = myObject;
其中 myObject.id
是对象的 id
。
换句话说,我管理对象及其功能,让"群集源"管理和渲染簇。
我现在需要的是能够浏览现有群集以查找包含匹配某些id
的对象。
如何获得当前现有簇的列表/数组?
等于
的东西var clusterSource = new ol.source.Cluster(...);
**var clusters = clusterSource.getClusters();**
顺便说一句。
群集源具有getFeatures()函数。
clusterSource.getFeatures();