We have a large number of layers in our map and every user complains about the lack of ability to save what's turned on/off.So my task was to create some code that would store variables in local storage to remember what was checked, and then on-load setup the map for them. So I wrote some code that works from a button that reads all the layers and sublayers and gets the default visibility. However it doesn't read the current map settings. i.e. you can uncheck a layer and it still read true in this code. So how do I get the current check box setting, and how would I set it's value?What I have so far.
function getTheMapLayers() {
var theInfo2 = []
var theList2 =""
for (var j=0, jl=map.layerIds.length; j<jl; j++) {
theList2 = theList2 +"\n"+map.getLayer(map.layerIds).id+" - Map Service, Visible = "+ map.getLayer(map.layerIds).visible+"\n"
var items2 = dojo.map(map.getLayer(map.layerIds).layerInfos,function(info,index){
theInfo2[info.id] = ( "id: "+ info.id +" Name: "+ info.name+" Visibility: "+info.defaultVisibility);
theList2 = theList2 +"\n"+theInfo2[info.id]
});
};
alert(theList2);
};