AnsweredAssumed Answered

setVisibleLayers to a function

Question asked by gopre400 on Jan 26, 2016
Latest reply on Feb 5, 2016 by rscheitlin

Hi I dynamically create a listview based on data from SQL server, which lists maps layers and visibility. I can loop through list to create array or visible layers. This works great when I make a change in the listview but I would like to use the process to setVisibleLayers when the map is loaded. I am trying to set the setVisibleLayers method of layer to the same .get function I use elsewhere but the layers are not visible. I believe it is because listview has not been fully created yet. Is there a way I can set the visible layers this way?

var roadLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisappserv3.spokanecounty.org/ArcGIS/rest/services/Engineering/ENGINEERINGqueries_10/MapServer",

{ id: "roadLayer",                    

visible: true                 });

roadLayer.setVisibleLayers([$('#ulLayerVisibility input[type="checkbox"]:checked').map(function () {                   

var checkid = $(this).attr('id').split(":");                    

return checkid[1];                

}).get()]);                

map = new Map("map", {                    

extent: customExtentAndSR               

});                

map.addLayers([roadLayer]);

Outcomes