Select to view content in your preferred language

Legend widget 4x: poor performance with many layers but only a few visible

448
3
Jump to solution
06-24-2023 02:05 PM
Dirk_Vandervoort
New Contributor III

We are seeing ~25% performance degradation for JSAPI map applications that use a legend widget over the same map application that does not use a legend widget> This is observable when there are many layers and with only a few visible.

Has anybody else seen this behavior?

Context: ArcGIS Online hosted feature services and webmap secured via OAuth2. The webmap is consumed by the ArcGIS JavaScript application. The webmap consists of a basemap and about 250 layers, only 5 of which are visible at load.

I wonder if the legend widget is rendering symbology for all layers at load - and this is what is affecting performance. Nonetheless, our customers are noticing it.

0 Kudos
1 Solution

Accepted Solutions
David_McRitchie
Esri Contributor

This sounds about right as the Legend widget will need to make a request to each layer on the WebMap, particularly since 250 layers is a lot of requests to be made.

As a general rule of thumb I would recommend no more than 10 layers in any one WebMap as more than this can cause performance issues as requests will be made to every layer, regardless if these are visible or not.

 

Hope that helps,

David

Esri UK -Technical Support Analyst

View solution in original post

0 Kudos
3 Replies
David_McRitchie
Esri Contributor

This sounds about right as the Legend widget will need to make a request to each layer on the WebMap, particularly since 250 layers is a lot of requests to be made.

As a general rule of thumb I would recommend no more than 10 layers in any one WebMap as more than this can cause performance issues as requests will be made to every layer, regardless if these are visible or not.

 

Hope that helps,

David

Esri UK -Technical Support Analyst
0 Kudos
mleahy_cl
New Contributor III

I'm not sure if this would work, as I haven't tried it, but: what if, when you first load the webmap item and before you render anything on screen, you scan all the layers in the web map, and for any layers that are not visible make them hidden from the legend by setting the legendEnabled to false (or you could also author the web map to do this for layers that are not visible by default).

For each layer that you do this to, you'd then have to watch (once) its visible property, and turn the legendEnabled option back on once the layer becomes visible.

Maybe someone else knows for sure whether this could help.  If it is the start-up performance specifically related to the legend widget that's the issue, maybe it's worth a try.

0 Kudos
Dirk_Vandervoort
New Contributor III

Yeah, I've thought about various ways I might be able delay construction of the legend until after complete rendering of the webmap. 

Still haven't landed on anything solid yet.

0 Kudos