繁体   English   中英

如何在openlayers 3中获得对修改后的功能的引用

[英]How to get a reference to the modified feature in openlayers 3

使用OpenLayers 3修改功能,如何获得修改后的功能?

var features = new ol.Collection(editableLayer.getSource().getFeatures());
var modifyInteraction = new ol.interaction.Modify({
  features: features
})
map.addInteraction(modifyInteraction);
modifyInteraction.on("modifyend", modifyFeature, this);

当我去获取该功能时:

function modifyFeature(event)
{
    var feature1 = event.features.getArray()[0]; //this brings back all features
                                                //I want to know which specific
                                                //features was modified

    var feature2 = modifyInteraction.getFeatures(); //this did not work at all
}

我的问题是如何获得修改的实际功能的参考?

根据api docs ol.interaction.Modify doens不提供获取Featueres选项。 一种方法是添加一个常见的更改事件 - .on('change:'... - 在每个功能上,在事件被触发后你应该获得目标功能。否则你可以检查增加一个的修订计数器更改后的每个功能(但我不建议这样)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM