I'm working with QGIS 3.22.11-Białowieża. In my project, I have four layers and I need to show in the print composer the name of those that are visible, but only among the first three (I don't want to get the name of the fourth one that is always visible). The expression proposed in this post works well but it returns all visible layers (which is not what I want):
array_to_string(
array_foreach (
@map_layers,
layer_property(@element,'name')
)
)
To create the array of layers I'm interested in, I've tried the following
array_to_string(
array_foreach (
array (layer1, layer2, layer3),
layer_property(@element,'name')
)
)
But it returns the name of all layers in the new array, no matter if they're visible or not. I guess I need to use the is_layer_visible
function, but all my attempts have failed. How should it be written?
@map_layers_ids
variable.