We have to develop an application which will have lot of rich ui along with a map. For the map, I am using the arcgis javascript api which includes dojo. For UI components other than the map, I want to use a copy of dojo which I will host locally. How can I load both of these? I read this blog esri dojo, but this works with api 1.6, and I am using 3.6.
-
2If you load the local dojo first, I guess ArcGIS API will bypass loading its own. You can also use the compact build of the ArcGIS JS API, which only includes a small subset of dojo.– Petr KrebsSep 2, 2013 at 16:48
-
No , it does not– AnilSep 3, 2013 at 10:35
2 Answers
To load your custom UI tools along with ESRI's version of Dojo, you'll need to add the name and location of your custom package to the dojoConfig object in the script. Just before you load ESRI's JavaScript API in the head of document, set your dojoConfig similar to the following
<script type="text/javascript">
dojoConfig = {
async: true,
packages: [
{
name: "customUI",
location: "/js/customUI" // or wherever you keep your custom code
}
]
};
</script>
<script src="http://js.arcgis.com/3.6/"></script>
Then, later, you can call it in a require or define statement.
require(["customUI/DrawingTool", "esri/map", "dojo/ready"],
function (DrawingTool, Map, ready) {
ready(function () {
var map = new Map("mapdiv", {});
var myDrawingTool = new DrawingTool({ map: map});
// do whatever with it.
});
}
);
Here's some reading to help you set it up properly:
-
thanks for suggestion , i will give it try today and update on the same , however by ur answere u mean i can load DOJO 1.7 or dojo1.9 along with ESRI right?– AnilSep 4, 2013 at 13:32
-
It might be possible to load an older (or newer) version of Dojo, but be warned that esri's dojo-based components may break if you use a different version. If you want to use Dojo 1.7, you might look into v3.2 of the ArcGIS Javascript API. That's the latest version running on that version of Dojo– raykendoSep 4, 2013 at 13:40
changes to Dojo's loader in more recent versions of their API have made loading multiple versions and remapping namespaces substantially more difficult.
what exactly do you need to use that isn't included with Dojo 1.8.3 (packaged with JS API 3.6?)