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.

Can anyone explain how I can ovveride the dblclick event when I'm using an OpenLayers.Control.DrawFeature? I see there is parameter in the constructor for handlerOptions - Used to set non-default properties on the control’s handler. My handler is just an OpenLayers.Handler.Path.

I want to run some custom validation when a user double clicks so that they can continue the sketch should they fail.

Double click --> "you've drawn something stupid are you sure you want to finish?" --> No ---> carry on sketching

Thanks, James

share|improve this question
add comment

1 Answer

if you make some edit here OpenLayers / lib / OpenLayers / Handler / Path.js , you can reach what you want.

code:

/**
* APIMethod: finishGeometry
* Finish the geometry and send it back to the control.
*/
    finishGeometry: function() {
        var index = this.line.geometry.components.length - 1;
        this.line.geometry.removeComponent(this.line.geometry.components[index]);
        this.removePoint();
        this.finalize();
    },

    /**
* Method: dblclick
* Handle double-clicks.
*
* Parameters:
* evt - {Event} The browser event
*
* Returns:
* {Boolean} Allow event propagation
*/
    dblclick: function(evt) {
        if(!this.freehandMode(evt)) {
            this.finishGeometry();
        }
        return false;
    }

i hope it helps you...

share|improve this answer
    
Thanks Aragon - i've chucked my logic in there for now –  geo_james May 31 '12 at 14:32
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.