AnsweredAssumed Answered

Issue when stacking draw toolbars for point and polyline

Question asked by AGI_Alexander_Pleyer on Oct 30, 2017
Latest reply on Nov 2, 2017 by rscheitlin

I want to stack two different geometry draw toolbars with the ArcGIS API for JavaScript namely a point and a polyline.

The goal is to create a point with the first click and simultaneously start the polyline draw mode so that the polyline start and the point overlie each other.

I created a sample which partially works but the last part of the polyline is not recognized and won't be drawn to the map:

Codepen Sample

Is this a bug because of not intended use in the ArcGIS API or is there a way to fix this?

 

 

Code:

 

map.on("load", createToolbar);

function createToolbar(themap) {
pointToolbar = new Draw(map);
pointToolbar.on("draw-end", addToMap);
polylineToolbar = new Draw(map);
polylineToolbar.on("draw-end", addToMap);
}

on(dojo.byId('draw'), 'click', activateTool);

function activateTool() {
pointToolbar.activate(Draw["POINT"]);
polylineToolbar.activate(Draw["POLYLINE"]);
}

function addToMap(evt) {
var symbol;
if (evt.geometry.type == "point") {
pointToolbar.deactivate();
} else if (evt.geometry.type == "polyline") {
polylineToolbar.deactivate();
}
switch (evt.geometry.type) {
case "point":
case "multipoint":
symbol = new SimpleMarkerSymbol();
break;
case "polyline":
symbol = new SimpleLineSymbol();
break;
default:
symbol = new SimpleFillSymbol();
break;
}
var graphic = new Graphic(evt.geometry, symbol);
map.graphics.add(graphic);

Outcomes