I saw a portal item https://www.arcgis.com/home/item.html?id=690d7aecc9d643b2825e75587992040e and want to add it to my map (arcgis javascript API 4.11) using the following codes but it failed:
Layer.fromPortalItem({portalItem: item }).then(function(layer) { webmap.add(layer);});
I think this is due to the portal item has layer index in the URL and the Javascript API Layer.fromPortalItem function cannot handle this. The portal item display fine in arcgis online map viewer.
Can anyone help with this?
Interesting. It looks like there might be an issue with consuming a MapImageLayer (with dynamic layers enabled) as a portal item. Will bear more investigation.
Edit: This might be wrong. We can consume a MapImageLayer (with dynamic layers enabled) as a portal item. Not sure what is going on here. Maybe data specific. Cannot reproduce yet with a different item.
In the meantime, you can still consume the data via URL instead of portal item, as seen here:
We have search arcgis online function and need to add search result (portal item) to map.
Ok. Will investigate further.
Update: looks like this is an issue with the API. We will address it and get it fixed at a release in the near future.