Select to view content in your preferred language

Noob question: How to access the js API?

1105
3
Jump to solution
09-06-2012 06:50 AM
DonRea
by
Occasional Contributor
I apologize for the raw n00bness, but I have been searching the help area, documentation, and forums for 45 minutes, and I've come up empty. What do you need to do to get access to the API objects? Based on the examples I've looked at, I included this script
element in the head of my page:

<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis?v=2.3"></script>

But execution crashes on the first reference to the esri namespace. Clearly there is something this API beginner does not understand.
0 Kudos
1 Solution

Accepted Solutions
__Rich_
Deactivated User
You have to wait until all the resources that you've required have finished downloading, in that sample that Derek provided notice the:

dojo.addOnLoad(init);


line, that causes the init function to be called after all resources are available.

Note that dojo.ready is preferred these days...or the AMD approach once the JSAPI moves to it.

View solution in original post

0 Kudos
3 Replies
DonRea
by
Occasional Contributor
But I am already including a script element referring to the hosted API, as I said. These are the first two lines of my own scripting:

dojo.require ("esri.map");
var startExtent = new esri.geometry.Extent (2660574.997050, 204651.048340, 2750112.778497, 304942.427600, new esri.SpatialReference ({wkd : 102100}));


Execution halts on the second line with the error, "esri is not defined" The doc you pointed to, and the examples, and all the examples I looked at before posting, seem to indicate that having that script element is all that's required.
0 Kudos
__Rich_
Deactivated User
You have to wait until all the resources that you've required have finished downloading, in that sample that Derek provided notice the:

dojo.addOnLoad(init);


line, that causes the init function to be called after all resources are available.

Note that dojo.ready is preferred these days...or the AMD approach once the JSAPI moves to it.
0 Kudos