[英]Openlayers 6 get geometry of a modified feature
在 Openlayers 6 中修改后如何获得新的特征几何? 我在听modifyend事件。
源包含大约 100 个功能。 我怎样才能做到这一点?
var modify = new ol.interaction.Modify({
source: map_features_source
});
modify.on('modifyend', function (evt) {
console.log(evt.target);
});
map.addInteraction(modify);
我试过这个:
evt.features.getArray()[0].getGeometry().getCoordinates()
但它不起作用,因为我在数组evt.features.getArray() 中有很多元素。 我需要找到被修改的那个。
正如 Mike 在评论中所描述的,在 6.6.0 版本之前,源中的所有功能都在 modifyend 事件中返回。 只需要升级到最低版本,这将匹配修改后的功能:
evt.features.getArray()[0].getGeometry().getCoordinates()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.