Select to view content in your preferred language

Display layer legend symbol even if the layer is not visible on the map

286
2
Jump to solution
10-14-2024 07:40 AM
LakshanRasingolla
Emerging Contributor

The following image shows the layer list implementation of my ArcGIS map. There is a layer list option called 'Legend' which shows the legend of that respective layer within the item panel. 

Screenshot 2024-10-14 192526.png

Screenshot 2024-10-14 192616.png

 

 

 

 

 

 

 

 

However, the respective layer must be visible on the map to show the legend. But I need to show each layer's legend when clicking on the legend option regardless of its visibility on the map.

(current code is attached below

1) Is there a way to do the above implementation? 

Further once item panel make visible it shows a question mark symbol on the layer list item (Image below).

2) Is there a way to remove this? 

Screenshot 2024-10-14 200328.png 

 

0 Kudos
1 Solution

Accepted Solutions
Sage_Wall
Esri Contributor

Hi @LakshanRasingolla ,

You can use the respectLayerVisibility property on the Legend, and you can add a "legend" icon or any of the other calcite icons the question mark would be replaced.  The panel in an interactive element and the button is there to allow the user to expand and collapse the panel.

https://codepen.io/sagewall/pen/wvVJdOR

            new Legend({
              view: view,
              container: legendContainer,
              layerInfos: [{ layer: item.layer }],
              respectLayerVisibility: false,
            });

            item.panel = {
              content: legendContainer,
              icon: "legend",
              open: true,
            };

 

View solution in original post

2 Replies
Sage_Wall
Esri Contributor

Hi @LakshanRasingolla ,

You can use the respectLayerVisibility property on the Legend, and you can add a "legend" icon or any of the other calcite icons the question mark would be replaced.  The panel in an interactive element and the button is there to allow the user to expand and collapse the panel.

https://codepen.io/sagewall/pen/wvVJdOR

            new Legend({
              view: view,
              container: legendContainer,
              layerInfos: [{ layer: item.layer }],
              respectLayerVisibility: false,
            });

            item.panel = {
              content: legendContainer,
              icon: "legend",
              open: true,
            };

 

LakshanRasingolla
Emerging Contributor

@Sage_Wall  This worked. Thanks !

0 Kudos