如何删除Openlayers 4中的功能数组,而不是使用clear()

时间:2018-06-18 21:08:22

标签: javascript openlayers

removeFeature()函数效果很好,但在尝试从源中删除大量功能/标记时效果不是很好,因为它只删除了单个功能。 OL2中有一个功能可以执行此操作但在OL4中删除。

有没有解决这个问题的工作?

features.forEach(function(feature, ind, array){
      if(feature.id == selectedFeature)
      {
        // slow removing process as it removes a single feature from the source...
        tFeature.removeFeature(feature);
      }
    });

希望做这样的事情,而不是在迭代源头时删除一个特征。

var removeF = [];
features.forEach(function(feature, ind, array){
 if(feature.id == selectedFeature)
 {
   // push every features that needs to be removed..
    removeF.push(feature);
 }
});
// Remove it in one go..
tFeature.removeFeatures(removeF );

0 个答案:

没有答案