I have a page where I am loading jQuery using <script> tag. I also have another custom JS file referenced using <script> tag following jQuery <script> tag. My page also references other JavaScript libraries like - momentJS, jQuery.i18n
In custom JS file, I am loading ArcGIS 4.8 JavaScript API using $.getScript() function inside the callback function of $.getScript(), I am loading ArcGIS modules as below.
HTML script references -
<script >
//<![CDATA[
//]]>
</script>
</script>
<script >
//<![CDATA[
//]]>
</script>
customJS.js file -
var dojoConfig =
{
async:true,
deps:["jquery"],
packages: [{
name: "jquery",
location: "/sites/DW/_catalogs/masterpage/scripts",
main: "jquery-2.1.4.min"
},
{
name: "dojo",
location: "https://js.arcgis.com/4.8/dojo",
main: "dojo"
}]
};
$.getScript("https://js.arcgis.com/4.8/", function () {
require([
"esri/Map",
"esri/views/MapView",
"esri/Graphic",
"esri/geometry/Point",
"esri/symbols/PictureMarkerSymbol",
"esri/geometry/Extent",
"esri/config",
"dojo/domReady!"
], function (Map, MapView, Graphic, Point, PictureMarkerSymbol, Extent, esriConfig) {
var map = new Map({
basemap: "streets"
});
var view = new MapView({
container: "map",
map: map,
zoom:2
});
});
});
When I try to load my page, it throws an error 'multipleDefine' in dojo.js.
The variable dojoConfig declared and initialized to resolve any loading conflicts but it didn't resolve the error. If I remove this variable, it throws the same error. The error screen shot is attached.
I have not previously worked on AMD and I am sure I am doing something wrong. Can anyone help me fix this problem or provide any directions or documentation ? Any help or direction is appreciated.
Amol,
The dojo config has to be first thing in your html in a script tag. Normally I see the esri JS API added after the jQuery library in the main html also (not using jQuery getScript).