How to use modules not in the compact build of ArcGIS API for JavaScript

2181
3
Jump to solution
03-15-2012 07:09 AM
YohanBienvenue
Occasional Contributor II
Hi,

I read this page on how to use the compact build version of the ArcGIS API for JavaScript
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_compactbuild....

Since I need esri.tasks.GeometryService in my application, I added dojo.require("esri.tasks.geometry");

One thing I don't understand though, is when I look as the network tab of any browser, I see that all the files for dojo.require calls are downloaded last, AFTER all the other files I include through script tags, even though they are made BEFORE those other scripts tags.
I'm a bit confused because according to the doc those calls are supposed to be synchronous right?

What this does is create an error when my esri.tasks.GeometryService call is parsed because esri.tasks is not even defined yet (http://serverapi.arcgisonline.com/jsapi/arcgis/2.7compact/js/esri/tasks/geometry.xd.js is not downloaded yet).

So how do I add modules not in the compact api ?
Thanks


Here is my head, the esri.tasks.GeometryService call is made in the last file: index.js

<head>    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />    <title>GOinfra Inspection</title>        <script>       var dojoConfig = {          //Required if you have dojo widgets (aka.dijits) in your HTML markup          parseOnLoad: true       };    </script>        <!-- ArcGIS API for JavaScript 2.7, compact build (includes Dojo 1.6.1 but does not include all Dojo Widgets) -->    <link href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.7/js/dojo/dijit/themes/claro/claro.css" rel="stylesheet" type="text/css" />    <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.7/js/esri/dijit/css/Popup.css"/>    <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.7compact" type="text/javascript"></script>        <!-- Our ArcGIS API for JavaScript 2.7 Dojo includes - see readme.txt -->    <script type="text/javascript">       dojo.require("dojo.parser");                     // Required if you have dojo widgets (aka. dijits) in your HTML markup       dojo.require("esri.map");       dojo.require("esri.layers.FeatureLayer");       dojo.require("esri.dijit.Popup");       dojo.require("esri.dijit.InfoWindowLite");       dojo.require("esri.virtualearth.VETiledLayer");  // For Bing Maps       //dojo.require("esri.tasks._task");       dojo.require("esri.tasks.geometry");    </script>          <!-- jQuery 1.7.1  -->    <script src="jQuery/jquery-1.7.1.js"></script>        <!-- jQuery UI 1.8.18 - only the position helper functions, the rest is not included -->    <link rel="stylesheet" href="jQuery/jQueryUI/jquery-ui-1.8.18.custom.css" />    <script type="text/javascript" charset="utf-8" src="jQuery/jQueryUI/jquery-ui-1.8.18.custom.min.js"></script>        <!-- jQuery Mobile 1.1.0-RC1 -->    <link rel="stylesheet" href="jQuery/jquery.mobile-1.1.0-rc.1.css" />    <link rel="stylesheet" href="jQuery/jquery-mobile-custom.css" />     <!-- [YB 2012/02/29 We can use this file to modify the default css of jQuery Mobile] -->    <script src="jQuery/jquery.mobile-1.1.0-rc.1.js"></script>      <script src="jQuery/jquery-mobile-custom.js"></script>               <!-- [YB 2012/02/27 We can use this file to modify the global defaults of jQuery Mobile] -->        <!-- Mobiscroll plugin - DatePicker widget for mobiles -->    <link href="plugins/mobiscroll/mobiscroll-1.5.3.min.css" rel="stylesheet" type="text/css" />    <script src="plugins/mobiscroll/mobiscroll-1.5.3.min.js" type="text/javascript"></script>          <!-- Fidget plugins for additional touch gestures (e.g. pinch) -->    <script src="plugins/fidget/jquery.fidget.beta.1.js" type="text/javascript"></script>        <!-- PhoneGap 1.4.1 -->    <script type="text/javascript" charset="utf-8" src="phonegap/phonegap-1.4.1.js"></script>        <!-- Our stuff -->    <link rel="stylesheet" href="index.css" />    <script type="text/javascript" charset="utf-8" src="coordinateSystems.js"></script>    <script type="text/javascript" charset="utf-8" src="extents.js"></script>    <script type="text/javascript" charset="utf-8" src="util.js"></script>    <script type="text/javascript" charset="utf-8" src="index.js"></script>     </head>
0 Kudos
1 Solution

Accepted Solutions
derekswingley1
Frequent Contributor
Are you executing your ArcGIS JS API code inside a function called by dojo.ready (or dojo.addOnLoad, they're the same)? dojo.ready waits for the DOM to load AND waits for all modules that you've dojo.require'd to load.

View solution in original post

0 Kudos
3 Replies
derekswingley1
Frequent Contributor
Are you executing your ArcGIS JS API code inside a function called by dojo.ready (or dojo.addOnLoad, they're the same)? dojo.ready waits for the DOM to load AND waits for all modules that you've dojo.require'd to load.
0 Kudos
YohanBienvenue
Occasional Contributor II
Are you executing your ArcGIS JS API code inside a function called by dojo.ready (or dojo.addOnLoad, they're the same)? dojo.ready waits for the DOM to load AND waits for all modules that you've dojo.require'd to load.


ohh.. right I think you nailed it. I do have most if it inside my addOnLoad but I've made some refactoring recently and did move things in separate util functions, including that projectTo function I wrote that makes the geometry service call.
Ok, I completely forgot about this.. (I am new to Dojo).

Thanks Derek, you rock
0 Kudos
derekswingley1
Frequent Contributor
Glad to help. Can you mark my post as an answer?
0 Kudos