[OpenLayers-Users] Get drawn feature from map and add it to a layer.

Ambran amit.bracha.andersen at atkinsglobal.com
Mon Aug 24 09:29:36 EDT 2009


Hi

This should be a simple question.
I'm working on limiting a path to one single line. What I did was to fire a
function on "Point" event. A global var is counting the points created. In
this function when the global var is 2, I have an alert which pops up fine.

What I want to do instead of the alert, is add the drawn line to a layer. 
Afterwords I deactivate the draw control, and that's it.

This is my DrawFeature control:

...
line: new OpenLayers.Control.DrawFeature(vectors, OpenLayers.Handler.Path,
{callbacks: { "point": this.TwoClickPath.bind(this) }}),
...

And this is the function that is being fired:

TwoClickPath: function(e) {
    this.TwoClickPathCount++;
    if (this.TwoClickPathCount == 2) {
        /*
            Here I want to add the drawn line to a layer
        */  
        // alert("");  fires ok
        controls.line.deactivate();
        this.TwoClickPathCount = 0;
    }
},


How do I add the drawn line to a layer without double-clicking?

Thanks in advance
Amit
-- 
View this message in context: http://n2.nabble.com/Get-drawn-feature-from-map-and-add-it-to-a-layer-tp3503203p3503203.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090824/5266a3c6/attachment.html


More information about the Users mailing list