使用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
}
我的问题是如何获得已修改的实际功能的参考?
答案 0 :(得分:2)
根据api docs ol.interaction.Modify doens不提供get Featueres选项。一种方法是添加一个常见的更改事件 - .on('更改:'... - 在每个功能上,在事件被触发后,您应该获得目标功能。 否则你可以检查更改后的每个功能增加1的修订计数器(但我不建议这样做)