AnsweredAssumed Answered

Draw toolbar cancel last vertex

Question asked by maiklas on Aug 2, 2013
Latest reply on Sep 30, 2014 by gcontino

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);
    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));
} else {
    dt._points = [];

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?