在OL2中,我能够做到以下几点:
var drawControl = new ol.Control.DrawFeature(
myLayer,
ol.Handler.RegularPolygon, {
handlerOptions: {
sides: 4,
irregular: true
},
eventListeners: {
featureadded: function( e ) {
// process features
}
}
}
);
有没有办法在OL3中添加功能?我想要做的是在绘制后绘制特征。理想情况下,如果可能的话,我会在绘制之前对它们进行投影。
答案 0 :(得分:1)
// 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);
});