"esri/toolbars/Draw" and multipleDefine Error in API v.3.4

3437
4
Jump to solution
04-04-2013 03:17 AM
EndreStokseth
New Contributor
After updating to v3.4 I do get an "Error: multipleDefine" from dojoLoader on esri/toolbars/Draw.
I tried to update the Esri JS-API Draw example to use AMD, and I got the same error.

Also got the same Error using "esri/toolbars/Navigation".

Is Draw and Navigation included in other items like Map, using another namestyle (like "draw" instead of "Draw")?

Any idea what is going on?
-Endre

Draw example using AMD that fails:
<!DOCTYPE html> <html>   <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8">     <title>Maps Toolbar</title>          <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/dojo/dijit/themes/claro/claro.css">     <link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/esri/css/esri.css">     <style>       html, body {         height: 100%; width: 100%; margin: 0; padding: 0;       }     </style>          <script></script>     <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/"></script>     <script>         define([   "dojo/ready",   "esri/map",   "esri/toolbars/Draw",   "esri/graphic",   "esri/symbols/SimpleMarkerSymbol",   "esri/symbols/SimpleLineSymbol",   "esri/symbols/SimpleFillSymbol",   "dojo/_base/Color",   "dojo/_base/connect",   "dijit/layout/ContentPane",   "dijit/layout/BorderContainer",   "dijit/form/Button",   "dojo/parser"     ],function(ready, Map, Draw, Graphic, SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, Color, connect){     ready(function () {     var map, toolbar, symbol, geomTask;      function init() {    map = new Map("map", {      basemap: "streets",      center: [-15.469, 36.428],      zoom: 3    });        connect.connect(map, "onLoad", createToolbar);     }            function createToolbar(themap) {    toolbar = new Draw(map);    connect.connect(toolbar, "onDrawEnd", addToMap);     }      function addToMap(geometry) {    toolbar.deactivate();    map.showZoomSlider();    switch (geometry.type) {      case "point":     var symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_SQUARE, 10, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([255,0,0]), 1), new Color([0,255,0,0.25]));     break;      case "polyline":     var symbol = new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH, new Color([255,0,0]), 1);     break;      case "polygon":     var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255,0,0]), 2), new Color([255,255,0,0.25]));     break;      case "extent":     var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT, new Color([255,0,0]), 2), new Color([255,255,0,0.25]));     break;      case "multipoint":     var symbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_DIAMOND, 20, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new Color([0,0,0]), 1), new Color([255,255,0,0.5]));     break;    }    var graphic = new Graphic(geometry, symbol);    map.graphics.add(graphic);     }     init();         })        });             </script>   </head>   <body class="claro"> <div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%; height:100%;">     <div id="header" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'" style="height:75px;text-align:left;font-weight:bold;font-size:14px;color:#400D12;overflow:hidden;">       <span>Draw:<br /></span>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.POINT);map.hideZoomSlider();}">Point</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.MULTI_POINT);map.hideZoomSlider();}">Multipoint</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.LINE);map.hideZoomSlider();}">Line</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.POLYLINE);map.hideZoomSlider();}">Polyline</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.POLYGON);map.hideZoomSlider();}">Polygon</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.FREEHAND_POLYLINE);map.hideZoomSlider();}">Freehand Polyline</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.FREEHAND_POLYGON);map.hideZoomSlider();}">Freehand Polygon</button>       <!--The Arrow,Triangle,Circle and Ellipse types all draw with the polygon symbol-->       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.ARROW);map.hideZoomSlider();}">Arrow</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.TRIANGLE);map.hideZoomSlider();}">Triangle</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.CIRCLE);map.hideZoomSlider();}">Circle</button>       <button data-dojo-type="dijit/form/Button" data-dojo-props="onClick:function(){toolbar.activate(esri.toolbars.Draw.ELLIPSE);map.hideZoomSlider();}">Ellipse</button>     </div>     <div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">     </div> </div>   </body> </html>
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Frequent Contributor
Additional question to Class Draw:
If I would like to change the text in the Draw toolbar, I am using the esri.bundle as explained in the documentation: http://developers.arcgis.com/en/javascript/jsapi/draw-amd.html
Ex: esri.bundle.toolbars.draw.addPoint = "Add a new tree to the map";

Using AMD it fails referencing esri.bundle. Is there any AMD compliant for esri.bundle?


In the future, please post a new thread.

Here's an example showing how to load the module with the text strings for various API components and specifically how to access the default text for various drawing tools:  http://jsfiddle.net/frc64/

View solution in original post

0 Kudos
4 Replies
KellyHutchins
Esri Frequent Contributor
When loading the module Draw should be lower-case. Here's an example that shows this. Note that the module is lower-case but the alias we use for the toolbar (Draw) is upper-case.


      require(
        [
          "dojo/ready", "dojo/on", "dojo/dom", "dojo/_base/connect", "esri/map","esri/toolbars/draw", "esri/graphic", "esri/symbols/SimpleMarkerSymbol"
        ],
        function(ready, on, dom, connect, Map, Draw, Graphic, SimpleMarkerSymbol) {
          ready(function(){

            on(dom.byId("pointTool"), "click", function(e){
              window.toolbar.activate(Draw.POINT);

            });


            window.map = new Map("map",{
              basemap:"oceans",
              center:[-102,40], //long, lat
              zoom:5
            });
            window.map.on("load", function(){
               window.toolbar = new Draw(window.map);
               connect.connect(window.toolbar,"onDrawEnd", addToMap);
            });

          });

          function addToMap(geometry){
            //add the graphic to the map 
            var symbol = new SimpleMarkerSymbol();
            var graphic = new Graphic(geometry, symbol);
            window.map.graphics.add(graphic);
          }
        
        }
      );


0 Kudos
OttarViken_Valvåg
New Contributor III
You should make sure to update the documentation then:
http://developers.arcgis.com/en/javascript/jsapi/draw-amd.html
0 Kudos
EndreStokseth
New Contributor
Additional question to Class Draw:
If I would like to change the text in the Draw toolbar, I am using the esri.bundle as explained in the documentation: http://developers.arcgis.com/en/javascript/jsapi/draw-amd.html
Ex: esri.bundle.toolbars.draw.addPoint = "Add a new tree to the map";

Using AMD it fails referencing esri.bundle. Is there any AMD compliant for esri.bundle?
0 Kudos
derekswingley1
Frequent Contributor
Additional question to Class Draw:
If I would like to change the text in the Draw toolbar, I am using the esri.bundle as explained in the documentation: http://developers.arcgis.com/en/javascript/jsapi/draw-amd.html
Ex: esri.bundle.toolbars.draw.addPoint = "Add a new tree to the map";

Using AMD it fails referencing esri.bundle. Is there any AMD compliant for esri.bundle?


In the future, please post a new thread.

Here's an example showing how to load the module with the text strings for various API components and specifically how to access the default text for various drawing tools:  http://jsfiddle.net/frc64/
0 Kudos