Draw toolbar cancel last vertex

1063
2
08-02-2013 01:07 AM
mykLT
by
New Contributor II
Hello,

I need to cancel last vertex drawn using Draw toolbar with geometry types POLYGON or POLYLINE and do not interrupt drawing process (geometry should be redrawn).

I implemented it like this:

              
var dt = drawToolbar; // NOTE: from somewhere  
var points = dt._points;
if (points.length > 1) {
    var geom = dt._graphic.geometry;
    geom.removePoint(0, points.length - 1);
    points.splice(points.length - 1, 1);
    dt._graphic.setGeometry(geom);
                    
    var start = points[points.length - 1];
    var tempGeom = dt._tGraphic.geometry;
    tempGeom.setPoint(0, 0, start.offset(0, 0));
    tempGeom.setPoint(0, 1, start.offset(0, 0));
    dt._tGraphic.setGeometry(tempGeom);
} else {
    dt._points = [];
    dt._onMouseMoveHandler_connect.remove();
    dt._clear();
}


But as You can see, it uses private attributes. It would be nice, if ESRI would implement this functionality in later releases, because it's really useful, I think. Maybe someone has an idea how to avoid using privates?
0 Kudos
2 Replies
vittoriosanzari
New Contributor

thank-you

very useful

0 Kudos
GianniContino
New Contributor III

Hi,

thanks for the function,

but I'd like to know what rows 10..14 are written for..

are they necessary?

bye

Gianni

0 Kudos