Select to view content in your preferred language

drawing toolbar is not working :(

1461
3
10-24-2011 01:18 AM
shwetakunjadia
Emerging Contributor
Hi,

I have my app i m trying to add code for drawing toolbar but its not working in my case can anyone tell me what is the reason??

dojo.connect(toolbar, "onDrawEnd", addToMap);

addtoMap(map)  is not called in my case..

Thanks,
Shweta
0 Kudos
3 Replies
deleted-user-iPdcWUgWcsoy
Deactivated User
Hi!

Could you post some more Code? There are some differences in definition of the drawingToolbar in the editing-dijit between versions 2.3 and 2.4. Perhaps, there is a problem?

Greets
Martin
0 Kudos
shwetakunjadia
Emerging Contributor
Hi Martin thanks for replying..

code:

    

    <script type="text/javascript">
  
    dojo.require("esri.map");

  //Map ToolBar
    dojo.require("esri.toolbars.navigation");
    dojo.require("dijit.form.Button");
    dojo.require("dijit.Toolbar");

//Legend Display
    dojo.require("dijit.dijit"); // optimize: load dijit layer
    dojo.require("dijit.layout.BorderContainer");
    dojo.require("dijit.layout.ContentPane");
    dojo.require("dijit.layout.AccordionContainer");
    dojo.require("agsjs.dijit.TOC");

      //identify
      dojo.require("esri.dijit.Popup");

//Drawing Toolbar
dojo.require("esri.toolbars.draw");

     
       var map,navToolbar;
    

  var toolbar, symbol, geomTask;

 
      function init() {
    var j =0;
       esri.config.defaults.io.proxyUrl = "proxy.jsp";        //Setting to use proxy file
             esriConfig.defaults.io.alwaysUseProxy = false;
             esriConfig.defaults.io.timeout = 180000; 


             esri.config.defaults.geometryService = new esri.tasks.GeometryService("http://192.168.3.220:8399/arcgis/rest/services/Geometry/GeometryServer");

          
             //identify
             var popup = new esri.dijit.Popup({
                 fillSymbol: new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]))
               }, dojo.create("div"));
               
           
            
      // esriConfig.defaults.map.sliderLabel = null;
       var startExtent = new esri.geometry.Extent({"xmin":103.85127109630895,"ymin":1.3070378815658947,"xmax":103.85326530653509,"ymax":1.308755802035058,"spatialReference":{"wkid":4326 }});
     
map = new esri.Map("map",{
              infoWindow:popup,
              extent:startExtent
            });


         
       var imageryPrime = new esri.layers.ArcGISDynamicMapServiceLayer("http://192.168.3.220:8399/arcgis/rest/services/IWMSapp1/MapServer");
       //map = new esri.Map("map"); 
      
 
          
        map.addLayer(imageryPrime);
        dojo.connect(map);


         dojo.connect(map, "onLoad", createToolbar);
      }

  function createToolbar(themap) {
           //resize the map when the browser resizes
        
          toolbar = new esri.toolbars.Draw(map);
         
          dojo.connect(toolbar, "onDrawEnd", addToMap_map);
         
         
         }

         function addToMap_map(geometry) {
          // toolbar.deactivate();
           //map.showZoomSlider();
           navToolbar.deactivate();
          
            switch (geometry.type) {
               case "point":
                 var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 10, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 1), new dojo.Color([0,255,0,0.25]));
                 break;
               case "polyline":
                 var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASH, new dojo.Color([255,0,0]), 1);
                 break;
               case "polygon":
                 var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
                 break;
               case "extent":
                 var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]));
                 break;
               case "multipoint":
                 var symbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_DIAMOND, 20, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,0]), 1), new dojo.Color([255,255,0,0.5]));
                 break;
             }
             var graphic = new esri.Graphic(geometry, symbol);
             map.graphics.add(graphic);
         }
         
</script>

   <div id="tcontent6">
   <button  data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.POINT);map.hideZoomSlider();}">Point</button>
      <button data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.MULTI_POINT);map.hideZoomSlider();}">Multipoint</button>
      <button  data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.LINE);map.hideZoomSlider();}">Line</button>
      <button data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.POLYLINE);map.hideZoomSlider();}">Polyline</button>
      <button  data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.POLYGON);map.hideZoomSlider();}">Polygon</button>
      <button  data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.FREEHAND_POLYLINE);map.hideZoomSlider();}">Freehand Polyline</button>
      <button  data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.FREEHAND_POLYGON);map.hideZoomSlider();}">Freehand Polygon</button>
  </div>

Hi!

Could you post some more Code? There are some differences in definition of the drawingToolbar in the editing-dijit between versions 2.3 and 2.4. Perhaps, there is a problem?

Greets
Martin
0 Kudos
deleted-user-iPdcWUgWcsoy
Deactivated User
Next time, try to put your Code in a Code-Tag. Its more readable ;). Here are my opinions.

1. There is a connect, that doesn't trigger something.
dojo.connect(map);

2. You can try to assign the map "themap" to the drawingToolbar in
function createToolbar(themap)

3. Connect to "onLoad"-Event before you add layers. In your case, the "onLoad"-Event doesn't trigger. It triggers until one or the first layer is been added.

I tend to the 3rd opinion ;).
Give me a reply if it works.

Greets
Martin
0 Kudos