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')
Solved! Go to Solution.
Hello,
Lloyd please try to use '==' instead of '==='. I this this might be an issue.
For example -
if (layerId == 6) {
..........
else if ( layerId == 10) {...}
}
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";
}}
I'm still trying to figure this one out.
Hello,
Lloyd please try to use '==' instead of '==='. I this this might be an issue.
For example -
if (layerId == 6) {
..........
else if ( layerId == 10) {...}
}
Duh, thanks!