Select to view content in your preferred language

How To Reference Group Layer

1039
4
Jump to solution
03-30-2017 11:13 AM
LloydBronn
Frequent Contributor

I'm trying to create and if/else loop for three sublayers in a group layer. If it's the group layer (0) then the sublayers have certain labels. If it's group layer (4) then the sublayers have other labels, etc. 

Here's what I've tried. I've also tried arrays [0] instead of '0'.

if(identifyParams.layerIds === '0'){
                              
                              if(layerName === '10% Damage Risk'){
                                   layerLabel = '24 Hour Forecast';
                                   label = "10% Damage Risk";
                                   }
                                   
                              else if(layerName === '90% Apple Damage Risk'){
                                   layerLabel = '24 Hour Forecast';
                                   label = "90% Apple Damage Risk";
                                   }
                                   
                              else if(layerName === 'Overall Damage Risk'){
                                   layerLabel = '24 Hour Forecast';
                                   label = "Possible Damage";
                                   }
                                   
                              }
if(identifyParams.layerIds === '4'){
                              
                              if(layerName === '10% Damage Risk'){
                                   layerLabel = '48 Hour Forecast';
                                   label = "10% Damage Risk";
                                   }
                                   
                              else if(layerName === '90% Apple Damage Risk'){
                                   layerLabel = '48 Hour Forecast';
                                   label = "90% Apple Damage Risk";
                                   }
                                   
                              else if(layerName === 'Overall Damage Risk'){
                                   layerLabel = '48 Hour Forecast';
                                   label = "Possible Damage";
                                   }
                                   
                              }

I've also tried, but it didn't work. 

if(layerName === '24 Hour Forecast')
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hello, 

Lloyd please try to use '==' instead of '==='. I this this might be an issue.

 For example -
if (layerId == 6) {
..........

else if ( layerId == 10) {...}
}

View solution in original post

4 Replies
LloydBronn
Frequent Contributor

Instead of using group layers, I'm just referencing the layer ID. I still can't get it to work. When I click this layer, I get "no information available" in the popup. If I change it back to layer name, it works. 

     if(layerID === '2'){ 
                                   layerLabel = '24 Hour Forecast';
                                   if(feature.attributes['Pixel Value'] === '10.000000'){
                                        label = "10% Damage Risk";
                                   }
                                   else if(feature.attributes['Pixel Value'] != '0.500000'){
                                        label = "No Damage Risk";
                                   }}‍‍‍‍‍‍‍‍
0 Kudos
LloydBronn
Frequent Contributor

I'm still trying to figure this one out. 

0 Kudos
by Anonymous User
Not applicable

Hello, 

Lloyd please try to use '==' instead of '==='. I this this might be an issue.

 For example -
if (layerId == 6) {
..........

else if ( layerId == 10) {...}
}

LloydBronn
Frequent Contributor

Duh, thanks! 

0 Kudos