gis - 如何获得对 openlayers 3 中修改功能的引用

标签 gis 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 不提供获取特征选项。一种方法是在每个功能上添加一个常见的更改事件 - .on('change:'... - 在事件被触发后,您应该获得目标功能。
否则,您可以检查修订计数器,该计数器在更改后每个功能都会增加 1(但我不建议这样做)

关于gis - 如何获得对 openlayers 3 中修改功能的引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34797972/

相关文章:

python - geopandas df 中的形状点几何到纬度/经度列

r - 如何在全局文件中找到像素(单元格)的 4 个坐标(lat-long)?

javascript - 我们可以使用 html 标签和 css 来设置 openlayers 中的功能样式吗?

openlayers-3 - 在 OL3 中将 drawend 添加到源后如何捕获事件?

node.js 和 geoserver CORS

从草地 gis 导出多个栅格

python - “模块”对象没有属性 'OSMGeoAdmin'

javascript - 生成两个已知点之间的坐标

Openlayers 3 移除绘制的特征

javascript - Geoserver - 使用 DWITHIN 过滤点