I have this for my legend function:function addLayerList(layers) {
var layerList = [];
dojo.forEach(layers, function(layer){
if(layer.layerInfos){
dojo.forEach(layer.layerInfos, function(info,index){
info.id = layer.id;
info.subId = index;
layerList.push(info);
})
}else{
layerList.push(layer);
}
});
if (layerList.length > 0) {
//create a menu of layers
layerList.reverse();
var menu = new dijit.Menu({
id: 'layerMenu'
});
dojo.forEach(layerList, function (layer) {
menu.addChild(new dijit.CheckedMenuItem({
label: layer.name || layer.title,
checked: layer.visible,
onChange: function (e) {
if (layer && layer.declaredClass === 'esri.layers.LayerInfo') {
var l = map.getLayer(layer.id);
var ids = []
if(e){
ids.push(layer.subId)
}else{
ids.push(-1);
}
l.setVisibleLayers(ids);
} else if (layer.type === 'Feature Layer'){
layer.setVisibility(!layer.visible);
}
}
}));
});
var button = new dijit.form.DropDownButton({
label: i18n.tools.layers.label,
id: "layerBtn",
iconClass: "esriLayerIcon",
title: i18n.tools.layers.title,
dropDown: menu
});
dojo.byId('webmap-toolbar-center').appendChild(button.domNode);
}
Is there a way to specify which on the my services are visible and which are not by using there ID Numbers?Any help is much appreciated.Bill