-1

I am writing code for developing interactive maps using the ArcGIS API and Dojo classes.

It works fine, until I define some modules such as "esri/toolbars/draw" or some other modules. These give an error: http://localhost/esri/toolbars/draw.js 404 (Not Found)

My question is, if I am using many other modules such as 'dojo/_base/declare', 'dojo/_base/lang', 'dojo/on', 'dojo/Deferred', 'esri/map' and many others, why can the program not load 'esri/toolbars/draw'? Interestingly, it searches for it in localhost, which is not the right place to look since I am not using the ArcGIS API locally.

I am wondering if someone can kindly help me with this. Below is a sample of my code:

require({
async: true,
parseOnLoad: true,
baseUrl: "/myApp/",
aliases: [
['text', 'dojo/text']
],
packages: [{
name: 'controllers',
location: 'js/controllers'
}, {
name: 'services',
location: 'js/services'
}, {
name: 'utils',
location: 'js/utils'
}, {
name: 'widgets',
location:  'js/widgets'
}, {
name: 'app',
location: 'js',
main:'main'
}]
}, ['app']);
___________________________________________ widgets/edit/drawTools.js
define([
'dojo/_base/declare',
'dojo/_base/lang',
'dojo/on',
'dijit/_WidgetBase',
'dijit/_TemplatedMixin',
'dojo/dom-class',
'text!widgets/edit/drawTools.html',
'esri/graphic',
"esri/toolbars/draw",
"esri/symbols/SimpleMarkerSymbol", 
"esri/symbols/SimpleLineSymbol",
"esri/symbols/PictureFillSymbol",     
"esri/symbols/CartographicLineSymbol",
"esri/Color"
    ], function(
    declare, lang, on, _WidgetBase, _TemplatedMixin, domClass, template,      graphic, Draw, SimpleMarkerSymbol, SimpleLineSymbol,
    PictureFillSymbol, CartographicLineSymbol, Color
    ) {


        return declare([_WidgetBase, _TemplatedMixin], {

            templateString: template,
            map:null,
            options:{},

            constructor: function(options) {
                this.options = options;
                this.map = this.options.map;
            },

            postCreate: function() {
                tb = new Draw(this.map);
                tb.on("draw-end", '_addGraphic');
            }

            function _addGraphic(evt) {
        }
        })
    })
Tim Malone
  • 3,364
  • 5
  • 37
  • 50
samira
  • 1

1 Answers1

0

Your runtime configuration for dojo is not correct. Please refer the documentation. here

Note that not all configuration options can be set at runtime. In particular, async, tlmSiblingOfDojo, and pre-existing has tests cannot be changed once the loader is loaded. Additionally, most configuration data is shallow copied, which means that you couldn’t use this mechanism to, for example, add more keys to a custom configuration object—the object would be overwritten

Try to use the default way of adding dojoConfig. Also, dojoConfig must be added before adding the esri api url.

<script>
    dojoConfig= {
        parseOnLoad: true,
        async: true
        package: [{
            "name": "agsjs",
            "location": location.pathname.replace(/\/[^/]+$/, "")+'/agsjs'
          }]
    };
</script>

Dojo api is part of esri api so adding explicit url for dojo is not required.

T Kambi
  • 1,389
  • 2
  • 9
  • 16