-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Description
Hello,
Apologies in advance if some of this doesn't make sense, I am new to Magento and RequireJs so this might be a simple fix, at least I hope it is.
I am currently trying to implement an external JS API (https://developers.arcgis.com/javascript/latest/sample-code/index.html ) within a Magento based application and am running into some issues which I was hoping someone might be able to help with. The issues are arising because the arcgis js plugin is based off RequireJs similarly to Magento itself.
I was able to get the ArcGIS JS API fully working in a standalone HTML application but am running into issues as soon as this solution is integrated with Magento.
I have followed the tutorial in the following github repository:
https://github.com/Esri/jsapi-resources/tree/master/4.x/bower/requirejs
The main difference I can see between this example and how our application works within Magento is that the example loads requirejs after setting the dependency value whereas our application already has requirejs before the user ever gets to this map page.
Window.require = {
Deps: [‘app/main’]
};
Therefore I have changed the define statements in the main.js file to be “require” statements instead and referenced the main.js file from my phtml file, this means that all the necessary js files are loaded as expected and no errors occur, the callback function is never hit however.
If I change the require to look for a different js file which is not using requirejs then the file is loaded without issue.
I have also taken out all of the files needed in the require statement and tried to load them one at a time but still my alert below never occurs when I try any of the files which are using require.
require([
'esri/Map',
], function() {
alert("esri Map loaded");
});
I think the core of the issue is the fact that require js has already loaded in my application before hitting this page and I probably just need an update to the require config settings somewhere but I can’t figure out what change that is…
Has anyone come across an issue like this before when using an external js api which relies on require? Or has anyone ever used the arcgis js api within Magento? I would really appreciate any guidance or help at all as this is becoming a major issue for my team.
Thanks a lot :)