Thanks for the suggestion.
I got something confused which is how to turn the ArcGIS API for JavaScript Sandbox into a widget code,
especially when I plan to have the two functions initToolbar and addGraphic:
function initToolbar() {
tb = new Draw(map);
tb.on("draw-end", addGraphic);
// event delegation so a click handler is not
// needed for each individual button
on(dom.byId("info"), "click", function(evt) {
if ( evt.target.id === "info" ) {
return;
}
var tool = evt.target.id.toLowerCase();
console.log(tool);
map.disableMapNavigation();
tb.activate(tool);
});
}
in this function, tb.on("draw-end", addGraphic); I don't know how to invoke the "draw-end" function by calling the addGraphic.
function addGraphic(evt) {
//deactivate the toolbar and clear existing graphics
tb.deactivate();
map.enableMapNavigation();
// figure out which symbol to use
var symbol;
if ( evt.geometry.type === "point" || evt.geometry.type === "multipoint") {
symbol = markerSymbol;
} else if ( evt.geometry.type === "line" || evt.geometry.type === "polyline") {
symbol = lineSymbol;
}
else {
symbol = fillSymbol;
}
map.graphics.add(new Graphic(evt.geometry, symbol));
}
I am trying to understand the enableMapNavigation() function, it seems that there is not such function anymore.
Any idea?
Thanks,