shaun_weston-eagle-co-nz-esridist

Toggle Visbility

Discussion created by shaun_weston-eagle-co-nz-esridist on Nov 7, 2011
Latest reply on Nov 25, 2011 by Xhosa
I think I must be missing something very basic here, but all I want to do is have toggle working for map services. When the checkbox is checked, show the layer and when the checkbox is unchecked, hide the layer. The showing the layer bit works, but the hide does not. I've tried a lot of different methods and the only one that works is removeAllLayers()?

 function visibleDPLayers() {
  var DPlayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis.mstn.govt.nz/ArcGIS/rest/services/DistrictPlan/MapServer");
  map.addLayer(DPlayer);
  
  if (legend.DPCheckbox.checked == true) {
   alert ('show')
   DPlayer.show();
  }
  else {
   alert ('hide')
   DPlayer.hide();
  }
 } 

Outcomes