Map Layers Custom Widget Bugs/Enhancements

468
1
09-19-2024 12:57 PM
Brian_McLeer
Frequent Contributor

I am working on a few enhancements to the Map Layers widget, which include having certain layers be expanded by default (referenced in this Community post) and having the layers collapse/expand when the tick box is checked or unchecked. Below, I have a few bugs and enhancements that have hit some roadblocks if anyone has any tips? I will include the ZIP of my current widget so far. 

BUGS: I have run into a snag where the legend of layers nested in group layers 3 levels or lower is not displaying (they are visible at the range shown in all images below). The legend icon stays greyed out. 

Brian_McLeer_0-1726774266289.png

They are displayed in the legend of the group container at the top, however. 

Brian_McLeer_1-1726774343472.png

I added the code from lines 19 - 24 (snippet below is from lines 369-392 in the widget.tsx file) to allow map layers to display the legend that is not in a 2nd level or beyond group layer which started displaying the legend based on the API documentation. My roadblock is finding the part that lets me have the legend show for all map layers, regardless of how far down they are nested in sublayers. 

 

        let actionGroups = {};
        listItem.actionsSections = [];

        this.trackLayerVisibility(listItem);

        if (!listItem.parent) {
            listItem.open = true;
        } else {
            listItem.open = false;
        }

        if (listItem.layer.sublayers) {
            listItem.panel = {
                content: 'legend',
                open: false // Set to true to expand legends by default
            };
        }

        if (listItem.layer.layer) {
            listItem.panel = {
                content: 'legend',
                open: false // Set to true to expand legends by default
            };
        }

 

The other issue I am encountering is that the legends are staying on when checking the radio button to off for Show legend in the configuration settings. 

Brian_McLeer_2-1726774412895.png

ENHANCEMENT: I would like to add hint text to the layers search that says "Filter Map Layers" and change the magnifying icon to a filter icon. 

Brian_McLeer_3-1726775035867.png

 

Brian
0 Kudos
1 Reply
JeffreyThompson2
MVP Frequent Contributor

In order to get to any arbitrary level, you will need to build a recursive widget. Here is an example.

https://community.esri.com/t5/experience-builder-custom-widgets/popup-identify-controller/ta-p/14956...

GIS Developer
City of Arlington, Texas