Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am developing a web map application in the ArcGIS API for Javascript.

I two have ArcGISDynamicMapServiceLayer layers that I am trying to run a simple query task on. The code I am using works in other applications doing the same task with different data.

My problem is, when I load the app (tried both Firefox and Chrome) in a browser, the map itself won't load (indefinite load screen). Console in both browsers shows this error:

ReferenceError: esri is not defined.

Comment #13 on this Esri forum post alludes to the DOM issue, but I need help understanding how to handle the issue. Also, it's possible that the DOM thing is not the issue at all.

So, does anyone have experience with this error? How have you worked around it?

Thanks so much for your input.

UPDATE: This is the code that is actually throwing the error:

var scalebar = new esri.dijit.Scalebar({ map: map, attachTo:"bottom-left" });

Note that I have included the dojo require statement for that class:

dojo.require("esri.dijit.Scalebar");

And if I simply comment out that function, the same undefined error comes with the next esri object class referenced (which also has its appropriate dojo require statement in the doc).

share|improve this question
4  
Please post code to reproduce the issue. It is almost certainly that you're referencing something in the esri namespace before the API is loaded. –  Derek Swingley Mar 2 '13 at 1:00
    
Did you require the map module? ``` require(esri/map); ``` or ``` dojo.require(esri.map); ``` –  Gautham Badhrinathan Mar 3 '13 at 18:18
    
@Gautham Yes, the map module is included. –  Badmagis Mar 4 '13 at 15:19
1  
@Badmagis as shown in all the SDK samples, wrap your JS that uses esri.* classes in a function called by dojo.ready, for instance: help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/… –  Derek Swingley Mar 4 '13 at 18:16
2  
Not to discourage you, but if you are following any of the hundreds of examples on the arcgis js site re @Derek, you shouldn't need to ask this. Start with working examples -- modify them in small chunks -- revert back when you have problems. –  awesomo Mar 4 '13 at 18:34
show 3 more comments

1 Answer 1

I've seen that happen if you don't put your JavaScript API code into something like an init function like so:

function (init) {
            map = new esri.Map("map", {
                basemap: "streets"
            });
...
}

dojo.ready(init);
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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