With our update to XPages version 9 and the Esri ARcgis javascript api v 3.5, we're having problems with our dojo namespaces resulting in a defineAlreadyDefined error. There are a few similar problems listed here (Using Durandal dojoConfig and ESRI Maps, How can I fix this AMD path conflict?), but even with that help we are unable to get it working. I believe the issue is the dojoConfig syntax - any thoughts or help would be appreciated!
Here is a simple version of our xpage source code with js:
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:styleSheet
href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dijit/themes/claro/claro.css">
</xp:styleSheet>
<xp:styleSheet
href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri/css/esri.css">
</xp:styleSheet>
<xp:script clientSide="true">
// dojo.registerModulePath("esri","http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri");
dojoConfig = {
baseUrl: "http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri",
packages: [
{
name: 'dojo',
location: "http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojo/"
},
{
name: 'dojox',
location: "http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/dojo/dojox"
},
{
name: 'esri',
location: "http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/js/esri"
}
]};
</xp:script>
<xp:script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.5/"
clientSide="true">
</xp:script>
<xp:dojoModule name="esri.map"></xp:dojoModule>
</xp:this.resources>
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script><![CDATA[var map;
function init(){
var map = new esri.Map("mapDiv", {
center: [-56.049, 38.485],
zoom: 3,
basemap: "streets"
});
}
dojo.ready(init);
]]></xp:this.script>
If we include the dojo.registerModulePath command, the map does load (at least in FF), but with the error. Without it, the esri dojo doesn't load - it's looking in the wrong place for the esri files.
OK, this was a problem for me too! I've been able to get it working by using the following code:
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:this.resources>
<xp:script clientSide="true">
dojo.registerModulePath("esri","http://js.arcgis.com/3.8/js/esri");
dojoConfig = { baseUrl: "http://js.arcgis.com/3.8/js/esri",
packages: [ { name: 'esri', location: "http://js.arcgis.com/3.8/js/esri" } ]};
</xp:script>
<xp:styleSheet href="http://js.arcgis.com/3.8/js/esri/css/esri.css" />
<xp:styleSheet href="http://js.arcgis.com/3.8/js/esri/dijit/css/Popup.css" />
<xp:dojoModule name="esri.map"></xp:dojoModule>
</xp:this.resources>
<xp:eventHandler event="onClientLoad" submit="false">
<xp:this.script><![CDATA[var map;
function init(){
var map = new esri.Map("mapDiv", {
center: [0,53],
zoom: 10,
basemap: "streets"
});
}
dojo.ready(init);
]]></xp:this.script>
</xp:eventHandler>
<div id="mapDiv" style="width:1000px;height:600px"></div>
</xp:view>
I think the order of scripts is important and you don't need to include the esri.map script twice.