使用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 不提供获取特征选项。一种方法是在每个功能上添加一个常见的更改事件 - .on('change:'... - 在事件被触发后,您应该获得目标功能。
否则,您可以检查修订计数器,该计数器在更改后每个功能都会增加 1(但我不建议这样做)
关于gis - 如何获得对 openlayers 3 中修改功能的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34797972/