chagan02

Trying to set layer visibility with dojo buttons, not working...

Discussion created by chagan02 on May 22, 2014
Latest reply on May 23, 2014 by chagan02
Hey guys,

Well I keep chugging along.  Next issue I have ran into is using dojo buttons.  I'm trying to activate layers when a particular button is fixed.  Was just gonna use the ole radio buttons but I found this http://maps.rosreestr.ru/arcgis_js_api/sdk/help/jssamples/map_agol.html online which uses the dojo buttons.

However, I can get the button to activate onClick.  I placed a console.log() command inside of the function to make sure that the two were taking to each other, and they aren't.  I have tried various combinations and I cant seem to figure out why this wont work.  Code is below.  Any thoughts from anyone?

JS
    function changeMap(layers) {
    console.log("Layers: " + layers);
    hideImageTiledLayers(layers);
    for (var i=0; i<layers.length; i++) {
      layers[i].show();
    }
     }

     function hideImageTiledLayers(layers) {
    for (var j=0, jl=map.layerIds.length; j<jl; j++) {
      var layer = map.getLayer(map.layerIds[j]);
      if (dojo.indexOf(layers, layer) == -1) {
     layer.hide();
      }
    }
     } 


HTML
       <div id="FFGButton">
       <h3>Observation</br> Interval</h3>
       <button dojoType="dijit/form/Button" onclick="changeMap([csv30min]);"> 30 Min</button>
       <button dojoType="dijit/form/Button" onClick="changeMap([csv60min]);"> 1 Hour</button>
       <button dojoType="dijit/form/Button" onClick="changeMap([csv120min]);"> 2 Hour</button>
       <button dojoType="dijit/form/Button" onClick="changeMap([csv180min]);"> 3 Hour</button>
       <button dojoType="dijit/form/Button" onClick="changeMap([csv360min]);"> 6 Hour</button>
       </div>

Outcomes