[英]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.