4.16 > 4.21 Upgrade Questions

490
4
01-21-2022 06:45 AM
joshk6656
New Contributor

Good morning all,

I recently inherited an React app using ArcGIS JS API 4.16. The app is also using webpack, and as most of you probably know, it wasn't until shortly after 4.16 that webpack played nice with the API. For this reason, I decided to try and tackle the upgrade to 4.21.

I believe everything is mostly working, but I've encountered one bug I can't quite figure out. The application has some functionality where you can give it a URL, top level or child, and it will load the layers.

On 4.16, I could feed it the following:

arcgis/rest/services/IN_AL/MapServer and it would loop through all the layers, and load them.

Group Layer (/MapServer/0)
--Layer (/MapServer/1)
--Layer (/MapServer/2)
Another Group Layer (/MapServer/3)
--Layer (/MapServer/4)

This involved .load()ing each layer. It looks like something changed between 4.16 and 4.21 that I can't pinpoint in any of the change logs that is failing when I .load() the GroupLayer.

As I am looping through them, they are being loaded like FeatureLayer({url: urltoLayerhere}.load().

Could anyone point me in the right direction?

Thanks in advance.

0 Kudos
4 Replies
BlakeTerhune
MVP Regular Contributor

Are you getting an error message anywhere that would help troubleshoot the issue?

0 Kudos
Stacy-Rendall
New Contributor III

FeatureLayer.load() is a Promise in recent versions - are you definitely using it as a Promise?

Can you a Catch and see if it is silently throwing any errors?

0 Kudos
joshk6656
New Contributor

I'm not sure why I did not include the error.

"feature-layer-source:unsupported-type","feature-layer-source:unsupported-type"

This is happening on this:

FeatureLayer({url: urltoLayerhere(which is a GroupLayer)}.load()

The issue is if url is a GroupLayer, it fails.

The code is taking a MapImageLayer, then looping through the sublayers, and trying to load them all as FeatureLayers to get their capabilities.

I guess this was allowed in 4.16, but now you cannot load a GroupLayer as a FeatureLayer?

Would there be a way to filter out the GroupLayers after loading the MapImageLayer? I see it in the object, but I don't think its accessible.

0 Kudos
Stacy-Rendall
New Contributor III

Ah... I haven't done a lot with sublayers, but what I did do was with something > 4.16, it all seemed pretty straight forward.

I'd recommend taking a good read of the docs for MapImageLayer and SubLayer, as you should be able to do what you want in a more standard way. Note you can also create a feature layer from a SubLayer 

0 Kudos