在 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/