I am having problems using the array below for loading layers into a map.
var layers= [
{ "id": "geothermal",
"url": "http://gisweb.unr.edu/ArcGIS/rest/services/Geologic/MapServer",
"label": "Great Basin Geothermal Data",
"type": "dynamic",
"queryLayers": [8],
"visible": true
},
{ "id": "geothermalExplore",
"url": "http://gisweb.unr.edu/ArcGIS/rest/services/Explore/MapServer",
"label": "Great Basin Exploration Data",
"type": "dynamic",
"queryLayers": [6],
"visible": false
},
{ "id": "geothermalFav",
"url": "http://gisweb.unr.edu/ArcGIS/rest/services/FavLayers/MapServer",
"label": "Great Basin Favorability Data",
"type": "dynamic",
"queryLayers": [6],
"visible": false
},
{ "id": "geothermalPhy",
"url": "http://gisweb.unr.edu/ArcGIS/rest/services/Geophysall/MapServer",
"label": "Great Basin Geophysical Data",
"type": "dynamic",
"queryLayers": [6],
"visible": false
}
];
Now depending on the order of list determines if there will be an error(a layer not being added). I've isolated it to this service:
{ "id": "geothermalPhy",
"url": "http://gisweb.unr.edu/ArcGIS/rest/services/Geophysall/MapServer",
"label": "Great Basin Geophysical Data",
"type": "dynamic",
"queryLayers": [6],
"visible": false
}
If it is placed in the array before any other object it causes the others to error out(the message is that the object is undefined). It only happens in IE. Here is the function that adds the layers.
function AddAllLayers() {
for (var i = 0, il = layers.length; i < il; i++) {
var info = geothermalLayers;
//console.log(info.url)
var layer;
//Determine if the map is dynamic or tiled
if (info.type == 'dynamic') {
layer = new esri.layers.ArcGISDynamicMapServiceLayer(info.url, {
id: info.id,
visible: info.visible
});
}
else {
layer = new esri.layers.ArcGISTiledMapServiceLayer(info.url, {
id: info.id,
visible: info.visible
});
}
//console.log(layer);
layer.label = info.label;
//Only doing one queryLayer now
layer.queryLayer = info.url + "\\" + info.queryLayers[0];
dojo.connect(layer,"onError",function(error){
console.log(error.message);
});
map.addLayer(layer);
}
}
Any insight would be appreciated.
... View more