gpt4 book ai didi

javascript - OpenLayers 3 Draw Interaction onFeature 添加事件

转载 作者:行者123 更新时间:2023-11-27 22:52:50 25 4
gpt4 key购买 nike

在 OL2 中我能够执行以下操作:

var drawControl = new ol.Control.DrawFeature(
myLayer,
ol.Handler.RegularPolygon, {
handlerOptions: {
sides: 4,
irregular: true
},
eventListeners: {
featureadded: function( e ) {
// process features
}
}
}
);

有没有办法访问 OL3 中添加的功能?我想做的是在绘制特征后对其进行投影。理想情况下,如果可能的话,我会在绘制它们之前对其进行投影。

最佳答案

// draw is an instance of ol.interaction.Draw
// when draw ended but the feature was not added yet to ol.source.Vector
draw.on('drawend', function(evt){
console.info(evt.feature);
});

// vectorSource is an instance of ol.source.Vector
// added to source
vectorSource.on('addfeature', function(evt) {
console.info(evt.feature);
});

关于javascript - OpenLayers 3 Draw Interaction onFeature 添加事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37923155/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com