Select to view content in your preferred language

Can we separate out the layers in to separate sections(not ExpB sections) based on any condition in Map-Layers widget

337
3
01-31-2025 07:16 PM
Vara_PrasadM_S
Frequent Contributor

Hi Team,

Is there a way to separate out (like two different  Map-Layers widgets in same widget) the list of layers in Map-Layers dynamically based on some characteristics of the layer, for example Editable or Readonly layers. We will load layers dynamically also, so those should also be dynamically should go into the corresponding section.

Any optimal way of customizing the Exp Builder's (V1.16) Map-Layers widget.

Hi @JeffreyThompson2,

could you please suggest me on this.

Thanks in advance

With Regards

0 Kudos
3 Replies
JeffreyThompson2
MVP Frequent Contributor

A few thoughts:

  • With statically loaded layers this could easily be accomplished by removing the unwanted layers from a Map Layer Widget with the options in the Settings Panels.
  • Adding the list-mode: 'hide' property to a layer will hide it from all Map Layers Widgets.
  • It is usually easier to make a Custom Widget from scratch than trying to modify an ESRI Widget. But that may not be a practical option if you need all the Data Actions in the Map Layers Widget.
  • Looking at the source code for the Map Layers Widget, the hide/show layers is managed by the customizeLayerOptions. I would look at overwriting these options as a customization path.
GIS Developer
City of Arlington, Texas
0 Kudos
Vara_PrasadM_S
Frequent Contributor

Hi @JeffreyThompson2 , 

I could able to achieve this by customizing Map-Layers widget to show only editable layers using below additional code line.

listItem.hidden = listItem?.layer?.capabilities?.operations?.supportsEditing ? false : true
 
Now, I am trying to change the 'checkbox' to toggle the layer visibility to JimuUI's Switch. Could you please guide me how can I achieve this.
 
Thanks in advance
 
With Regards
0 Kudos
JeffreyThompson2
MVP Frequent Contributor

https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#visibility...

The Map Layers Widget is based on the Layer List Widget of the JavaScript API. I was able to find the line that sets the eyes or checkboxes option in the Widget. It's line 323 in widget.tsx and it is using options from the API. I don't know of any practical way to substitute in the Switch component. Switches themselves are ultimately checkboxes with some fancy CSS. Maybe you can overwrite the CSS and make your own Switch.

https://www.w3schools.com/howto/howto_css_switch.asp

GIS Developer
City of Arlington, Texas
0 Kudos