AnsweredAssumed Answered

Problem with toolbar.deactivate(); method for draw toolbar

Question asked by EncinitasGIS on Jun 7, 2013
Latest reply on Jun 12, 2013 by khutchins-esristaff
I took a look at the drawing tools example and got it up and running fairly quickly (I seperated out the html code and the js code into two seperate files). 

I see the toolbar.deactivate(); method works in the example but I can't get it to work in my code.  I'm adding it everywhere and I even created a button to deactivate it. 

dojo.connect(dojo.byId("drawPolygon"),"click", function(){

It just doesn't work!

Here's my code


<!-- ******************** Spatial Select Button ***************************-->
       <div id="info">
      <div>Select a shape then draw on map to add graphic</div>
          <button id="deactivateDraw" data-dojo-type="dijit.form.Button"  data-dojo-props='onClick:function(){ initToolbar();}'>DeActivate</button>
    <button id="drawExtent" data-dojo-type="dijit.form.Button"  data-dojo-props='onClick:function(){ initToolbar();}'>Extent</button>
         <!--button id="drawPolygon" data-dojo-type="dijit.form.Button">Polygon</button-->
<!-- ******************** End Spatail Select Button ***************************-->[/HTML]

 var tb; //toolbar for draw tools      //*************** TOOLBAR CODE ******************************   function initToolbar() {         tb = new esri.toolbars.Draw(map);         dojo.connect(tb, "onDrawEnd", addGraphic);             dojo.connect(dojo.byId("drawExtent"),"click", function(){           tb.activate(esri.toolbars.Draw.EXTENT);     map.hideZoomSlider();         });            dojo.connect(dojo.byId("deactivateDraw"),"click", function(){          tb.deactivate();          map.showZoomSlider();           });       }         //*************** END TOOLBAR CODE ******************************     function addGraphic(geometry) {         // try to deactivate the toolbar and clear existing graphics    var symbol;         tb.deactivate(); //doesn't work   map.showZoomSlider(); //works; //works          switch (geometry.type) {           case "point":           case "multipoint":             symbol = new esri.symbol.SimpleMarkerSymbol();             break;           case "polyline":             symbol = new esri.symbol.SimpleLineSymbol();             break;           default:             symbol = new esri.symbol.SimpleFillSymbol();             break;         }         var graphic = new esri.Graphic(geometry, symbol);;     tb.deactivate();            }  //*************** END TOOLBAR CODE ******************************