dojo multipleDefine error with mapkitJS and ArcGIS esri-loader

旧街凉风 提交于 2021-01-28 01:11:19

问题


I cannot figure out where MapkitJS and esri-loader are having issues together. From researching on here and elsewhere, it seems like there is likely a naming conflict with another package. Here is a link of the resolved issue for esri-loader. I read all the pages on that link.

I have a site that uses both MapkitJs and ArcGIS. Mapkit has always worked fine until I brought in ArcGIS. Both scripts are lazy loaded via a provider. After reading about the issues, I wait until Mapkit is initialized before loading the ArcGIS script.

The first thing I noticed was the ability to rotate maps in Mapkit immediately went away (it loads, then takes it away after about 1/2 second). That was my first hint something is conflicting.

If I remove esri-loader's call loadModules, which loads the script, the rotate works again. If I add it again (even if I don't specify any modules to add), it break Mapkit rotate.

Here is the main problem. If I create a mapkit map first, then try to create an ArcGIS map, it pops the error. But if I create an ArcGIS map first, and then the mapkit second, it's fine (except the apple mapkit map can't rotate).

I wish I could provide more information, but I don't even know where to start on this one. Please ask me what you need...

I uploaded a demo page to my site. If you go to https://dieselplanning.com/ 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 on apple maps as it accepts rotation then decides not to shortly after creation.

However, if you go to https://dieselplanning.com/test 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.


回答1:


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 it, 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.



来源:https://stackoverflow.com/questions/62778380/dojo-multipledefine-error-with-mapkitjs-and-arcgis-esri-loader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!