Hello,
I am using ArcGIS Experience Builder version 1.17 and trying to integrate the sample widget use-map-components2 from the official Esri GitHub repository.
When I add the sample widget to my Experience Builder app, the widget renders, but neither the Legend nor the Layer List is displayed. Instead, I see messages like “No legend” or “No items to display,” even though the standard Experience Builder Legend widget displays the map legend correctly for the same map.
Environment
Steps to Reproduce
Additional notes
Expected behavior
The Legend and Layer List web components should display the legend and layers of the selected map, just like the standard Experience Builder widgets.
Actual behavior
The web components render, but show “No legend” or “No items to display,” even though the map has visible layers and the standard widgets work.
Question
Is there an additional configuration or step required to get the ArcgisLegend and ArcgisLayerList web components working in Experience Builder 1.17?
Is this a known limitation or bug with the current version?
Thank you for your help!
Hi @othke .
The sample widget has a logic flaw.
The initialization of JimuMapViewComponent and ArcgisLegend/ArcgisLayerList is not synchronized.
If ArcgisLegend or ArcgisLayerList initializes more slowly, when the onActiveViewChange event is triggered, legendRef.current and layerListRef.current may still be null, so the view cannot be assigned to these two components.
A better approach is to use the onArcgisReady event of ArcgisLegend and ArcgisLayerList to assign the currently active view within the event.
This double assurance ensures that both components can reliably update their view in response.