Select to view content in your preferred language

Expand Grouped Layers by Default

6418
44
07-20-2023 08:25 AM
Status: Open
Labels (2)
lmurrayADOT
Regular Contributor

It would be helpful to have the option for grouped layers to be expanded by default within the Experience Builder Map Layers Widget.  Ideally, it would help to select which grouped layers are expanded and which are compressed by default.  However, even just having the ability to expand all grouped layers by default would make it easier for users to locate the layer they want to view.

44 Comments
Geraldine

OK, thanks @TonghuiMing !

lmurrayADOT

Glad to see this was implemented.  Thank you.  @TonghuiMing, just curious, are there plans to provide the ability to expand only specified groups?  

MattiasEkström

@TonghuiMing 
It's great that we can finally expand all layers by default, but like ImmurayADOT and others I'd really like to have full control over which layer groups are expanded and which aren't.
In my case, I especially want to be able to have map image layers expanded and their sublayers collapsed.

LindseyStone

I second, third, and fourth @MattiasEkström comment.  When I have a map image service added to a map that has several layers within it,  I would prefer to have this initial map image layer expanded by default,  but all my group layers under that not expanded.  The ability to pick and choose would be awesome or the ability where it recognize that it is a map service and allows the expansion of that by default.  It is so annoying that in map layers widget you just see the service main layer and have to expand from there.

Brian_McLeer

I have the same situation that @MattiasEkström and @LindseyStone are wanting to have implemented. I copied the out of the box widget and customized it to have the parent group layer expanded by default, but group layers within collapsed. Having this functionality out of the box would be much easier to maintain. 

LindseyStone

@Brian_McLeer How did you get just the parent group layer to expand and keeping all the other group layers collapsed?  I'm in v1.16 of Developer Edition.  I added the listIem.open = true in the below code of the widget.tsx.  When I added this all groups were expanded but not the legend.  I would prefer to only have the parent group layer expanded and have all subgroups and legend collapsed.

defineLayerListActionsGenerator = (isTableList = false) => {
    return async (event) => {
      const listItem = event.item
      let actionGroups = {}
      listItem.actionsSections = []
	  
	  listItem.open = true
	 
      if (!isTableList && this.props.config?.useMapWidget && this.props.config?.enableLegend && listItem.layer.legendEnabled) {
        if (typeof listItem.layer?.id !== 'string' || !listItem.layer.id.startsWith('jimu-draw')) {
          listItem.panel = {
            content: 'legend',
            open: listItem.layer.visible && this.props.config?.showAllLegend
          }
        }
      }

 

 

Brian_McLeer

@LindseyStone I had to do a few steps of manipulation, I had to hardcode in layers to hide from showing in the layers list. Ultimately lines 247-252 and 402-406 perform the function. The code that I modified broke the actions however, such as export data, decrease transparency, etc. It broke it so that only the top layer of the group layer will perform the action, even if you select the action on a layer further down the list. Ultimately the result was to have the parent layer expanded by default but some functionality was lost. My preference is hopefully in a couple of versions of EB DE I can go back to the out of the box widget. 

Update on 4/2/25: No longer maintaining this 1.15 widget due to improvements below for 1.17

 

 

 

TonghuiMing

Thanks for your thoughts! @lmurrayADOT @MattiasEkström Regarding your request, we will keep a note and see if we could enhance it later. Feel free to create a support ticket if needed.

EricLacoursierePQ

We would like to have the option to develop the first level at opening as well.

Thanks

Brian_McLeer

I have been playing with the out of the box map layers widget for 1.17 and made some updates to fit the needs of our uses. 

Highest level group layer expanded by default

Tick boxes or eyes collapse or expand layers automatically

Supports regular widget options 

Brian_McLeer_0-1743628789071.png

 

I cannot add an attachment here, but I posted it to the custom widgets board here. 

https://community.esri.com/t5/experience-builder-custom-widgets/map-layers-widget-custom-1-17/m-p/16...