Add portal item failed

499
4
11-05-2019 12:24 PM
XiaowenHuang
New Contributor

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?

Tags (1)
0 Kudos
4 Replies
Noah-Sager
Esri Regular Contributor

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:

https://codepen.io/noash/pen/LYYdzKE 

XiaowenHuang
New Contributor

We have search arcgis online function and need to add search result (portal item) to map.

0 Kudos
Noah-Sager
Esri Regular Contributor

Ok. Will investigate further.

Noah-Sager
Esri Regular Contributor

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.

0 Kudos