Javascript OpenLayers 3在功能添加事件上绘制交互
在OL2中,我能够做到以下几点:Javascript OpenLayers 3在功能添加事件上绘制交互,javascript,openlayers-3,Javascript,Openlayers 3,在OL2中,我能够做到以下几点: var drawControl = new ol.Control.DrawFeature( myLayer, ol.Handler.RegularPolygon, { handlerOptions: { sides: 4, irregular: true }, eventListeners: { featureadded: fu
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);
});