Problem with dojo in JavaScript?

640
6
08-22-2011 12:47 PM
BenReilly
New Contributor
Sorry I can't be more specific in the title. The other day, 2 of my JavaScript maps stopped working properly while a third kept working. The only thing the two that stopped working have in common is that they contain dojo elements. I brought up Firebug, and received this error when trying to load:

TypeError: Unable to draw graphic (geometry:null, symbol:null): this._gc is null
[Break On This Error] if(!dojo._hasResource["dijit._base.man...h","tr","xx","zh","zh-cn","zh-tw"]);
arcgis?v=2.4 (line 48)


Line 48 in my code is CSS- in ESRI's JavaScript document, at http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4, it contains information about Dojo. Is this a known error, or did I screw something else up? Changing to version 2.3 through 2.1 did not fix my problem, either.
0 Kudos
6 Replies
derekswingley1
Frequent Contributor
Can you post your code?
0 Kudos
BenReilly
New Contributor
My code is attached.
0 Kudos
JoeJeurissen
New Contributor
I believe it is telling you that you cannot add those feature layers without a basemap.
0 Kudos
StephenLead
Regular Contributor III
Ben,

It's hard to test this exactly since we don't have access to your internal server, but here are some suggestions.

Define startExtent before assigning it to the map:

 var spatialRef = new esri.SpatialReference({wkid:102100});
 var startExtent = new esri.geometry.Extent();
 startExtent.xmin = -9879338;
 startExtent.ymin = 5286787;
 startExtent.xmax = -9878257;
 startExtent.ymax = 5287623;
 startExtent.SpatialReference = spatialRef;

 map = new esri.Map("mapDiv",{extent:startExtent });


Rather than calling:

  dojo.addOnLoad(init);
  dojo.addOnLoad(initParking);


call initParking in the map's onLayersAddResult event:

dojo.connect(map, "onLayersAddResult", initParking);


Does that make any difference?

Steve
0 Kudos
derekswingley1
Frequent Contributor
Adding a base map, creating the extent before referencing it in the map constructor and creating an extent with a spatial reference that matches the basemap's gets it working for me. Take a look at the attached, modified version of your code. No problems with dojo...
0 Kudos
BenReilly
New Contributor
Looks like I got caught up in trying to figure out the error message, and forgot to change the spatial extent from a previous basemap I was using. (The basemap in my posted code was supposed to be on. I had turned it off temporarily trying to trouble shoot).

Thanks to everyone for helping me figure out another rookie mistake.
0 Kudos