[GIS] openlayers draw feautre(line, polygon) callback

javascriptopenlayers-2

I need to enable feature drawing functionality. Code:

var drawingControl = new OpenLayers.Control.DrawFeature(someLayer, OpenLayers.Handler.Path);
map.addControl(drawingControl);

But I also need to do some actions when drawing is done, on double click.
Therefore, how can I define a dblclick callback (for example, add there console.log("1"))?

Best Answer

You can pass a callback function to OpenLayers.Control.DrawFeature featureAdded property, which will be automatically called after you finishing drawing the geometry.

I can image some code like this:

var drawingControl = new OpenLayers.Control.DrawFeature(someLayer, OpenLayers.Handler.Path, {featureAdded: onFeatureAdded});
map.addControl(drawingControl);

function onFeatureAdded(){
    console.log("1");
}