Hi all,<br><br>I need to draw lines with only two vertexs so when the second vertex is added the draing must end.<br><br><br>I&#39;ve done it so far creating a new handler.path where I control the length of the geometry components. When is bigger than 2 I run the finalize function so it ends.<br>
That works fine but I think there must be a better way of doing it?<br><br>I have also tried registering the sketchmodified event of the control from the main html page. <br><br>The issue here is that I do not know how to deactivate the drawing control without throwing and error. (feature is null, on Vector.js (line 617, in drawFeature function)<br>
<br>any ideas?<br><br>the code.<br><br>//DRAWING CONTROLS<br>drawControls = {<br>    point: new OpenLayers.Control.DrawFeature(pointLayer,<br>        OpenLayers.Handler.Point),<br>    line: new OpenLayers.Control.DrawFeature(lineLayer,<br>
        OpenLayers.Handler.Path, options),<br>    polygon: new OpenLayers.Control.DrawFeature(polygonLayer,<br>        OpenLayers.Handler.Polygon, options)<br>};<br><br>for(var key in drawControls) {<br>    map.addControl(drawControls[key]);<br>
}<br><br>//REGISTERING<br>drawControls.line.layer.events.on({<br>    &#39;sketchmodified&#39;: report<br>});<br><br><br>function report(param)<br>{<br>    if (param.feature.components.length&gt;2)<br>    {<br>        drawControls.line.handler.finalize();  <br>
    }<br>}<br><br><br>