Select to view content in your preferred language

multipleDefine error in dojoLoader

70928
14
01-07-2015 02:11 PM
ChristopherTotty
Deactivated User

I am working on a js application that uses ArcGIS JS (currently targeting 3.8, referencing through the arcgis cdn).  We have found an issue during internal testing where when the app loads and the dojo require/define chain resolves, periodically the app will fail to load with "multipleDefine" errors being thrown from dojoLoader in esri init.js.  We have a single computer running IE 10 that can easily replicate the error in one or two loads of the page.  Testing on another computer running IE 10 did not provide a replication of the issue.  I have tested on IE 11 as well and was able to replicate a few times over many loads of the app.  This hasn't been enough to go on to track down the cause.

We have a number of custom modules setup with the standard "define" structure.  It appears that when one of these modules loads, a group of the references in the define block fail with the multipleDefine errors.  As an example, there is a custom module that handles the setup and use of a BasemapGallery.  In the case of this module, the errors may occur when loading  'esri/dijit/BasemapGallery', 'esri/dijit/BasemapLayer', 'esri/dijit/Basemap', among others.  These 3 references in particular are only made within this single module in our entire app.

Any thoughts about what could be causing this issue?

Thanks

define([
    'dojo/_base/declare',
    'dijit/_WidgetBase',
    'dijit/_TemplatedMixin',
    'dijit/_WidgetsInTemplateMixin',
    'dojo/_base/lang',
    'dijit/form/DropDownButton',
    'dijit/DropDownMenu',
    'dijit/MenuItem',
    'dojo/_base/array',
    'dojox/lang/functional',
    'dojo/text!./Basemaps/templates/Basemaps.html',
    'esri/dijit/BasemapGallery',
    'esri/dijit/BasemapLayer',
    'esri/dijit/Basemap',
    'dijit/registry',
    'esri/layers/ArcGISTiledMapServiceLayer'
], function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin, lang, DropDownButton, DropDownMenu, MenuItem, array, functional, template, BasemapGallery, BasemapLayer, Basemap, registry, ArcGISTiledMapServiceLayer) {

    //anonymous function to load CSS files required for this module
    (function () {
        var css = [require.toUrl("gis/dijit/Basemaps/css/Basemaps.css")];
        var head = document.getElementsByTagName("head").item(0),
            link;
        for (var i = 0, il = css.length; i < il; i++) {
            link = document.createElement("link");
            link.type = "text/css";
            link.rel = "stylesheet";
            link.href = css[i].toString();
            head.appendChild(link);
        }
    } ());

    var customBasemaps = {
        //SNIP     
    };

    var agolBasemaps = {
        //SNIP   
    };

    // main basemap widget
    return declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
        templateString: template,
        widgetsInTemplate: true,
        mode: "agol",
        title: "Basemaps",
        mapStartBasemap: "hybrid",
        basemapsToShow: ["hybrid", "satellite", "streets", "topo", "gray", "oceans", "national-geographic", "osm"],
        validBasemaps: [],
        postCreate: function () {
            //SNIP
        },
        startup: function () {
            this.inherited(arguments);
            if (this.mode === "custom") {
                this.gallery.select(this.mapStartBasemap);
            } else {
                this.map.setBasemap(this.mapStartBasemap);
            }
        }
    });
});
Tags (4)
0 Kudos
14 Replies
DennisHunink
Deactivated User

I did had a similar issue lately. In the end it turned out there was a conflict wit jQuery UI loading stand-alone (not as a dojo package). Key is wait for jQuery UI to be loaded (blocked) before firing the DoJo loader.

See ArcGIS Javascript API broken after latest WordPress release

Not sure if this applies to your situation. But just in case...

0 Kudos
HaroldBostic
Frequent Contributor

I use this solution to solve my multiple loader issue when using Durandal.  It may help you.  I have a dojo_mod for 3.11

https://github.com/dgwalton/DurandalEsri/blob/master/Readme.md

0 Kudos
BrentHoskisson
Frequent Contributor

What fixed my similar issue is the "defer" keyword.  It makes the JavaScript API run only after everything else has loaded.

<script defer src="http://js.arcgis.com/3.13/"></script>

<script defer type="text/javascript" src="Scripts/gvMap.js"></script>

ChrisSmith7
Honored Contributor

Brilliant!

0 Kudos
ThomasGagne
Deactivated User

I had this same problem.  By removing

<script src="//cdnjs.cloudflare.com/ajax/libs/es5-shim/1.2.4/es5-shim.min.js" />

    

The error no longer displayed and the map loaded correctly every time, instead of 50% of the time.

0 Kudos