Basically I am trying to turn on/off layers in a dynamic service and have the functionality to toggle between tiled services. The problem I am having is that I think the code I am using to toggle between tiled services, which comes from the esri sample code, is turning off the dynamic layers. If I turn on/ off the dynamic layers before I change the tiled service the dynamic work fine. Once I toggle between the 2 tiled services the dynamic layer stops working. I am having trouble figuring out how to avoid this.
I am using the following function to update layer visibility for the dynamic layers:
function updateLayerVisibilitySPED() {
var inputs = dojo.query(".list_item"), input;
//in this application layer 0 is always on.
visible = [0];
for (var i=0, il=inputs.length; i<il; i++) {
if (inputs.checked) {
visible.push(inputs.id);
}
}
SPED.setVisibleLayers(visible);
}
Then I was using the following for the switching of the titled layers (I am pretty sure it is hiding the dynamic layer but I am not sure how to write the code to exclude it):
function initLayer(url, id) {
var layer = new esri.layers.ArcGISTiledMapServiceLayer(url, {id:id, "opacity":0.3, visible:false});
map.addLayer(layer);
return layer;
}
function changeMap(layers) {
hideImageTiledLayers(layers);
for (var i=0; i<layers.length; i++) {
layers.show();
}
}
function hideImageTiledLayers(layers) {
for (var j=0, jl=map.layerIds.length; j<jl; j++) {
var layer = map.getLayer(map.layerIds);
if (dojo.indexOf(layers, layer) == -1) {
layer.hide();
}
}
}
Any help or advice would be appreciated. Thanks
Jaclyn