OpenLayers 3 Draw Interaction onFeature 添加事件
OpenLayers 3 Draw Interaction onFeature added event
在 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);
});
在 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);
});