Need help with map.GetLayer()

1943
1
05-08-2014 06:43 AM
JuneAcosta
Occasional Contributor III
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.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);

0 Kudos
1 Reply
JuneAcosta
Occasional Contributor III
Sorry-- I forgot to include the URL to our shortlist map.

http://ccmaps.carlsbadca.gov/shortlistDEV/index.html
0 Kudos