Layer list wouldn't update visibility when check box clicked

742
3
Jump to solution
10-15-2012 01:50 PM
DavidBoyd
New Contributor
I'm very new to Javascript and making slow, steady progress.  Still figuring it out.  I got the layer list to draw in a tab to the left, but the updatelayervisibility function apparently isn't firing when I click a check box.  This could be something very simple, but I can't find it.  Thanks for any help!
0 Kudos
1 Solution

Accepted Solutions
__Rich_
Occasional Contributor III
Your "vop" object isn't in scope inside your "updateLayerVisibility" function, so this will fail:

vop.setVisibleLayers(visible);


Since you've hard-coded the Id of your vop layer here:

var vop = new  esri.layers.ArcGISDynamicMapServiceLayer(     "http://dswcapps.dcr.virginia.gov/ArcGIS/rest/services/dnh/vop/MapServer",     {         id: 'vop',         opacity: 0.45     } );


....one quick way you could get a reference to the layer is to replace that broken line with:

 map.getLayer("vop").setVisibleLayers(visible);

View solution in original post

0 Kudos
3 Replies
CraigMcDade
Occasional Contributor III
there is a spelling error early in your code. This may or may not be the problem:

var landsResults, riversResutls;


It is spelled correctly when you reference it later in the code.
0 Kudos
__Rich_
Occasional Contributor III
Your "vop" object isn't in scope inside your "updateLayerVisibility" function, so this will fail:

vop.setVisibleLayers(visible);


Since you've hard-coded the Id of your vop layer here:

var vop = new  esri.layers.ArcGISDynamicMapServiceLayer(     "http://dswcapps.dcr.virginia.gov/ArcGIS/rest/services/dnh/vop/MapServer",     {         id: 'vop',         opacity: 0.45     } );


....one quick way you could get a reference to the layer is to replace that broken line with:

 map.getLayer("vop").setVisibleLayers(visible);
0 Kudos
DavidBoyd
New Contributor
Problem solved, and I learned something too.  Thanks to both of you!!!!
0 Kudos