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'm seeing the following error when attempting to add a tiled and feature layer to the same map when using the ArcGIS Server JS API 3.1:

TypeError: Unable to draw graphic (geometry:null, symbol:null): _c is undefined http://serverapi.arcgisonline.com/jsapi/arcgis/3.1compact/js/dojo/dojo/DeferredList.js Line 8

After defining the map and adding a basemap, I'm iterating through a list of JSON layer definitions, building each layer based on its definition, then adding it to the map. The pseudo code is:

dojo.connect(map, "onLoad", function {
   for layerDef in layerDefs:
      if layerDef.type == tiled:
         layer = buildTiledLayer
      if layerDef.type == feature:
         layer = buildFeatureLayer
      map.addLayer(layer)
}

If I add just the tiled layer, or just the feature layer, there are no problems - it's only when I add both together that I see the error message. Once the error message has shown, an infoWindow is not shown when clicking on the feature layer.

This forum post lead me to suspect the problem may be due to the timing of adding the layers - during debugging I found that if I remove the map.addLayer line, and instead push the layers into an array, I can manually enter map.addLayers(layerArray) in Firebug, once the map has finished loading. In this case, both layers add correctly.

Adding a FeatureLayer ARCGIS JavaScript API isn't relevant as I know the feature layer definition is correct - the feature layer adds without error if it's added without the tiled layer.

Similarly, I believe that the layers are correctly defined since each is loaded correctly without the other.

Does anyone have any advice as to why this error might be occurring, and how to resolve the error?

Thanks

share|improve this question
    
I had this same error: I observed that changing the "addLayer" function in one place or another, did also change the order that the "xhr cancelled" errors appeared with other console messages. In my opinion, I suspect this happens when ArcGIS Server is installed in a not-very-powerful machine. I did what you suggest and simply worked, thanks! PD - It is interesting to read "Version 2" section in this link to get a bit more of information: personal.psu.edu/mqg5150/863/Lesson05/reflection.html –  iamgin Dec 8 '12 at 20:23
add comment

2 Answers 2

You're right that the layer isn't fully loaded. There's an event that tells you when layers are loaded :

onLayerAddResult(layer, error)

As of v2.0 it triggers after specified layer has been added to the map.

OR

onLayersAddResult(results)

Which triggers after all layers are added to the map using the map.addLayers method.

http://developers.arcgis.com/en/javascript/jsapi/map.html

Maybe better to use that rather than setting a timeout in your application since it's impossible to know exactly how long it will take to load.

share|improve this answer
add comment
up vote 3 down vote accepted

I think I found the answer, which was to insert a short pause before adding the layers.

//Add the layers, after pausing briefly
setTimeout(function(){
    console.log("pausing a few seconds");
    map.addLayers(mapLayers);
},1000);

After defining the layers from JSON in the loop, I'm running some other operations on the layers. I haven't had time to debug exactly, but presumably something in my code depends on the tiled layer being fully added to the map.

So in short, it appears that the resolution/workaround to the error TypeError: Unable to draw graphic (geometry:null, symbol:null): _c is undefined is to pause briefly.

share|improve this answer
    
I'm also putting masking tape over the warning light, and explicitly ignoring any error messages which contain that text. –  Stephen Lead May 22 at 23:05
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.