Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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"))?

share|improve this question
add comment

2 Answers

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");
}
share|improve this answer
add comment

Try using this event if you want to do action immediately after feature is added (no need for double click): featureadded Triggered when a feature is added

Something like this:

someLayer.events.on({
     "featureadded":
         function(e)
         {
            console.log("1");
         }
    });

If you still need double click examine this:

http://openlayers.org/dev/examples/click-handler.html

OpenLayers - is it possible for a feature to have both a single click and double click event?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.