jpacosta

Need help with map.GetLayer()

Discussion created by jpacosta on May 8, 2014
Latest reply on May 8, 2014 by jpacosta
I would like to customize the shortlist template by turning off a specific layer based on the selected tab. I found the code to make the change on the StoryMap forum, but I having some trouble with the code.
function init() {
       .......
       ........
       var layers = response.itemInfo.itemData.operationalLayers; 
  //for ( var x = 0; x < layers.length; x++){
   //alert(layers[x].id);
  //}
 
  if(_map.loaded){
   initMap(layers);
  } else {
   dojo.connect(_map,"onLoad",function(){
    initMap(layers);
   });
  }
  
 });


The map gets stuck once it hits trailLayer.setVisibility(false);When using Firefox I can see 'Trail_Lines_7339' being passed, but var trailLayer is undefined.
function initMap(layers) {
 
 trailLayer = _map.getLayer('Trail_Lines_7339');
 //trailLayer = _map.getLayer(_map.layers[1]);
 trailLayer.setVisibility(false);
 //alert(trailLayer);

Outcomes