Select to view content in your preferred language

ArcGIS Experience Builder 1.17 – Map Components Sample (use-map-components2) Not Displaying Legend or Layer List

192
1
3 weeks ago
Labels (2)
othke
by
New Contributor

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.

arcgis-components-not-working.PNG

Environment

  • ArcGIS Experience Builder: v1.17
  • Web Browser: Chrome

Steps to Reproduce

  1. Download or clone the arcgis-experience-builder-sdk-resourcesrepository.
  2. Copy the use-map-components2 widget folder into client/your-extensions/widgets in your Experience Builder installation (v1.17).
  3. Register the widget and add it to an Experience with a web map.
  4. Select a map widget in the widget settings.
  5. Observe that the widget renders, but the ArcgisLegend and ArcgisLayerList web components do not display any content, even though the map has layers and the standard Legend widget works.

Additional notes

  • The widget uses the recommended pattern: it gets the MapView from `JimuMapViewComponent` and assigns it to the web components via `ref`.
  • No errors are shown in the browser console, except for a TypeScript error about missing type declarations for `arcgis-map-components` (which I assume is expected).
  • The CSS for ArcGIS JS API is loaded, and the rest of the Experience Builder app displays correctly.
  • I have tried both `@arcgis/map-components-react` and `arcgis-map-components` imports as shown in the sample.

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!

0 Kudos
1 Reply
Allen_Zhang
Frequent Contributor

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.

Allen_Zhang_1-1748598033110.png

 

0 Kudos