Busy with the transformation to API 4.32 which requires a lot of code changes and headache. I managed to get almost everything working, except for one issue. I have 2 webMaps, one from portal 1, and one from another portal, portal 2. The user sees 2 representations of the webMaps by a thumbnail-button of the map. Depending on which thumbnail the user selects, the correct initialisation is done and the portal is set. So:
Button 1 -> portal 1 gets initialised and the mapView is displayed
Button 2 -> portal 2 gets iniitalised and the mapView is displayed
The web map is dynamically created in JavaScript by creating a <arcgis-map> element. The portal is set: esriConfig.portalUrl = <portalurl>;
It works for the first selection, mapMap from portal 1 or it works for the first selection, webMap from portal 2.
The issue:
The user must be able to change the web map by selecting the other button. I remove the <arcgis-map> element. and create everything from scratch dynamically in Javascript, but this second time I get this error:
message: "Failed to load portal item"
name: "webmap:load-portal-item"
AI gives a hint why this is not working:
Even when you set esriConfig.portalUrl before creating the <arcgis-map> element, the custom element internally uses the default portal unless it's fully re-imported or instantiated in a new JavaScript execution context. The component's internal API initialization only happens once per page. So once it's loaded (and bound to Portal A), changing esriConfig.portalUrl afterward doesn't affect it anymore.
This is a limitation of the ArcGIS Maps SDK Web Components (<arcgis-map>) — not the core ArcGIS JS API.
MY QUESTIONS:
Is this true? Is there a way to work around this?