Select to view content in your preferred language

Using webmap layer legend settings

684
3
Jump to solution
08-18-2022 06:48 AM
Labels (1)
JamesGough
Occasional Contributor

I have a legend component based on some of the ESRI examples, using the map.legendInfos list model. The legend works fine, however it does not seem to honor the webmap's settings for layer legends. All layers are shown in the legend even the ones that i have set to "hide in legend" in the web map.

 

With the autoFetchLegendInfos setting, does it simply fetch legends for all map layers without regard for the web map settings?

 

Is there a way to access the web map item details through the Map object? Or do I have to manually fetch them from the rest endpoint (/portal/sharing/rest/content/items/<item id>/data)?

 

0 Kudos
1 Solution

Accepted Solutions
JamesBallard1
Esri Regular Contributor

With the autoFetchLegendInfos setting, does it simply fetch legends for all map layers without regard for the web map settings?

Yes, it will fetch the legend information from every layer. You can get the web map json from the JsonSerializable properties, which are broken into a few categories:

  1. json - what is read and supported by the Runtime.
  2. unsupportedJson - things the Runtime knows about, but does not support.
  3. unknownJson - things the Runtime does not about, for example web map features released after Runtime.

 

View solution in original post

3 Replies
JamesBallard1
Esri Regular Contributor

With the autoFetchLegendInfos setting, does it simply fetch legends for all map layers without regard for the web map settings?

Yes, it will fetch the legend information from every layer. You can get the web map json from the JsonSerializable properties, which are broken into a few categories:

  1. json - what is read and supported by the Runtime.
  2. unsupportedJson - things the Runtime knows about, but does not support.
  3. unknownJson - things the Runtime does not about, for example web map features released after Runtime.

 

JamesGough
Occasional Contributor

That is very helpful, thanks! It looks like map.json.operationalLayers has what i need.

MarkGambordella
New Contributor III

Im not a coder and not sure how to follow the solution.  Did you find another way.

Need to remove repetitive layers from the legend. Within map viewer, I have turned off the "show in map legend" for each layer I do not wish to appear.  All but one layer is a feature layer on AGO, the other is from a rest service.  None are sublayers within the map view.  I have refreshed the web map and web app.  

Is there a setting in Experience builder that I am missing for turning off layers in a legend, or is there only one button within web map that needs to be turned off.  

Is there a work around?  I have researched several other discussions on the topic within ESRI and other websites.  Most just confirm the turn off show in legend button, and not to have a sub feature layer.

thanks for the help 

0 Kudos