Another multipleDefine error with dojoLoader and mapkitJs

07-07-2020 11:42 AM
New Contributor

I have a website where I allow the users to change their map they are looking at. It starts off showing mapkitjs, they click a button and it shows Esri. I'm writing this in React. I do not have JQuery in my project or Knockout.

I think mapkitjs and dojo loader are conflicting, I'm just not sure how. I'm getting the multipleDefine error when the Esri ArcGis map is created.

First I load the mapkitjs script and initialize it. Then, via esri-loader I load the arcgis scripts. Then I create the apple Map. Then, after the user clicks, I destroy that map and create the ArcGis map.

I first noticed there could be an issue because mapkitjs loses the ability to rotate if I call loadModules from esri-loader, even if it is empty.

If I load the ArcGis map first, then load the mapkit, it's fine (except the ability to rotate mapkit). I can switch back and forth between them. But if I create an apple map first, then an Esri map, it breaks. Of note, I don't get this error until I create the map. It does not happen when esri-loader finishes loading the modules. I can load the modules, wait a minute, then create the arcgis map (after the mapkit map) and it'll break there. I don't know where to start debugging this and searching the forums shows most things are jQuery related. I've made sure mapkit isn't loading jQuery onto my window, it's not.

I get the error

instrument.js:110 Error: multipleDefine
at r (dojo.js:5)
at Ia (dojo.js:21)
at dojo.js:22
at g (dojo.js:4)

and the next line

src: dojoLoader

Followed by that: 


  1. {pid: "esri", mid: "esri/portal/support/layersCreator", pack: {…}, url: "", executed: 0, …}
    1. cjs: {id: "esri/portal/support/layersCreator", uri: "", exports: {…}, setExports: ƒ, config: ƒ}
    2. def: ƒ W()
    3. defOrder: 661
    4. deps: (3) [{…}, {…}, {…}]
    5. executed: 5
    6. injected: 2
    7. mid: "esri/portal/support/layersCreator"
    8. pack: {main: "main", location: "../esri", name: "esri"}
    9. pid: "esri"
    10. require: ƒ (f,g,q)
    11. result: ƒ k()
    12. url: ""

The map loads, it just has no images (it's a white background). Can anyone help me with where to start looking? Thanks for the help.

I uploaded a demo page to my site. If you go to it'll start with an Esri map loaded first. It works, you can switch maps (bottom left button in the sidebar). You'll also see the compass rose at the bottom right flash for a second anytime the apple maps is created as it accepts rotation then decides not to shortly after creation.

However, if you go to it's the same exact page as the `ao` page, but it creates a mapkit map first. That will create issues when you swap maps.

0 Kudos
1 Reply
New Contributor

If you research these multiple defines there is normally another library creating the issue and the common answers are to load the ArcGis script after those libraries or load the libraries with dojo.

The problem here, I realized, is when you make a Mapkit map, it loads more scripts. So loading the mapkit API loads scripts, then creating a mapkit map loads more scripts. So what I have to do is load the mapkit API. Create a map, then destroy the map, then load the ArcGis API. It works after that.

The current problem now is figuring out when the create Map is done making all its calls, it has no method or listener to tell you when that is done.

0 Kudos