0

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

1

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");
}
1

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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