AnsweredAssumed Answered

Toggle layers error

Question asked by mcdade31 on Aug 27, 2012
Latest reply on Aug 27, 2012 by mcdade31
I have added code from the Dynamically Create Layer List sample to my app. It works as expected, except, it loads without my basemap.

I have a switch basemap dropdown that still populates with all the ESRI basemaps, however, they don't load when clicked. When I do click on one, it eliminates my DynamicMapServiceLayer.

I added the following in the init():

layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisprod2/arcgis/rest/services/Dynamic/CountyTest/MapServer");          if (layer.loaded) {           buildLayerList(layer);         }         else {           dojo.connect(layer, "onLoad", buildLayerList);         }

and then separate functions of:
function buildLayerList(layer) {         var items =,function(info,index){           if (info.defaultVisibility) {             visible.push(;           }           return "<input type='checkbox' class='list_item'" + (info.defaultVisibility ? "checked=checked" : "") + "' id='" + + "' onclick='updateLayerVisibility();' /><label for='" + + "'>" + + "</label>";         });          dojo.byId("layer_list").innerHTML = items.join(' ');          layer.setVisibleLayers(visible);         map.addLayer(layer);        }        function updateLayerVisibility() {         var inputs = dojo.query(".list_item"), input;              visible = [];          dojo.forEach(inputs,function(input){           if (input.checked) {               visible.push(;           }           });         //if there aren't any layers visible set the array to be -1         if(visible.length === 0){           visible.push(-1);         }         layer.setVisibleLayers(visible);       }

I get the following error in Chrome Developer Tools when I try to switch basemap
1. Resource interpreted as Script but transferred with MIME type tex/plain: "

Any ideas why the basemaps will not load initially or switch?