簡體   English   中英

Openlayers 6 獲取修改后特征的幾何形狀

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM