I am trying to create a button that allows a user to undo or cancel a current 
sketch using a DrawFeature control with OpenLayers.Handler.Path and 
OpenLayers.Handler.Polygon

If there are >= 2 points, then the button should call control.undo(), but if 
only 1 point, then it should call control.cancel()

Here is some code for setting up a polygon layer epolys:

dpoly: new 
OpenLayers.Control.DrawFeature(epolys,OpenLayers.Handler.Polygon,{id: 
'ctrldraw'})

here is one for a line layer elines:

dline: new OpenLayers.Control.DrawFeature(elines,OpenLayers.Handler.Path,{id: 
'ctrldraw'})

Here is my undo code:

function undoFunc() {
        //undo when digitising new features
        var drawctrls = map.getControlsBy("id", "ctrldraw");
        for (var i = 0; i < drawctrls.length; i++){
                ctrl = drawctrls[i];
                if (ctrl.active) {
                        ctrl.undo();
                }
        }
}

At the moment it just calls undo() but can't completely cancel().
Thanks,

Robert



This email and any attachments are confidential and intended solely for the 
addressee(s). If you are not the intended recipient, please notify us 
immediately and then delete this email from your system.

This message has been scanned for Malware and Viruses by Websense Hosted 
Security.
www.websense.com
_______________________________________________
Users mailing list
us...@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to