5

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.

  • 2
    If 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 Krebs Sep 2 '13 at 16:48
  • No , it does not – Anil Sep 3 '13 at 10:35
2

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:

  1. Defining Modules in Dojo (1.8)
  2. Loading custom modules while using Dojo CDN (via StackOverflow)
  3. How does package location work in Dojo (via StackOverflow)
  • 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? – Anil Sep 4 '13 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 – raykendo Sep 4 '13 at 13:40
0

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?)

  • I want to use DOJO 1.7 but not DOJO 1.8.3 since it is not approved in my company – Anil Sep 4 '13 at 13:33
  • Why is ESRI breaking when i load it for my application , i always get this.navigationManager is undefined in IE and mozilla and 'disableNavigation' of undefined – Anil Sep 16 '13 at 16:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.