I use version 4.28 of ArcGIS Maps SDK for JavaScript. I have a button that activate Draw object for drawing, for example, a polyline. But an user could change its mind after he/she pushed the button, so I added other button that should to interrupt (complete) the drawing action. So I added a code
document.getElementById("btnDrop").onclick = () => {
draw.complete();
}
that should interrupt the drawing action. But it does not work. Here a sample that I did in CodePen:
Sample for drawing polyline and a button for cancelling of drawing
So I need a help.
Solved! Go to Solution.
It seems I know how to solve my problem. I made changes in Sample for drawing polyline and a button for cancelling of drawing .
var toDraw = true;
....
document.getElementById("btnDrop").onclick = () => {
toDraw = false;
draw.complete();
}
....
action.on(
[
"vertex-add",
"vertex-remove",
"cursor-update",
"redo",
"undo"
],
updateVertices
);
//action.on("draw-complete", special);
....
function updateVertices(event) {
if (!toDraw)
return;
....
It seems I know how to solve my problem. I made changes in Sample for drawing polyline and a button for cancelling of drawing .
var toDraw = true;
....
document.getElementById("btnDrop").onclick = () => {
toDraw = false;
draw.complete();
}
....
action.on(
[
"vertex-add",
"vertex-remove",
"cursor-update",
"redo",
"undo"
],
updateVertices
);
//action.on("draw-complete", special);
....
function updateVertices(event) {
if (!toDraw)
return;
....