Tell me more ×
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 at 1:00
@DerekSwingley I will gladly post some code to get help with this, but my project has 111 lines of html and 267 lines of a separate but referenced JS file. I'm not sure which part of all that would be useful for diagnosis. For a little more information, the error is simply occurring at the line where the esri object is first used. If I comment out that function, the error will still happen at the next instance. – Badmagis Mar 4 at 15:30
Posting just the javascript will help. Any if you are doing this in the on load method, then just post everything from the top of the javascript section to the end of the onload. – Jamie Mar 4 at 16:35
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 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 at 18:34

1 Answer

Did you require the map module?

require(esri/map);

or

dojo.require(esri.map);

share|improve this answer
You should use the comments section to ask for clarification on a question, rather than the answer section. – Jay Guarneri Mar 3 at 18:57
@Jay I read this as a somewhat elliptical way to offer a solution. Granted, it appears to be a guess, so if the OP says this isn't the issue, we can then convert it to a comment. – whuber Mar 3 at 19:08
My mistake. I saw this in the 'review' section so it was taken out of context. – Jay Guarneri Mar 3 at 19:18
@Gautham Yes, the map module is included. – Badmagis Mar 4 at 15:19
@JayGuarneri I would have posted this in the comment section, but don't have enough reputation on this site yet. – Gautham Badhrinathan Mar 7 at 13:18
show 1 more 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.