Select to view content in your preferred language

Why aren't all layers displayed when using MapImageLayer without specifying sublayer? It seemed to work in version 4.4..

846
2
Jump to solution
07-12-2018 09:56 AM
JackFairfield
Frequent Contributor

In my simple JSBin example, why aren't all layers from my arcgis rest endpoint being shown?

Simple JS bin example 

According to the documentation, when adding a MapImageLayer to the map:

A Collection of Sublayer objects that allow you to alter the properties of one or more sublayers of the MapImageLayer. If this property is not specified, all the sublayers from the service are displayed as defined in the service. If an empty array is passed to this property then none of the sublayers from the service are displayed in the layer.

In my example, I am not specifying the sublayers property.  So why aren't all of my layers being included?

I noticed that if you change the ESRI JS API version back to 4.4, it works as expected:

I also inspected the network requests and compared the 4.4 api version to the 4.8 version:

4.4 Request

4.8 Request

For some reason, the "Layers" parameter doesn't seem to be correctly populated in the 4.5-4.8 version of the JS api.

This breaking change in the api wasn't listed in the release notes for js version 4.5.

Release notes for 4.5 

Thanks for any help debugging / finding a workaround for this issue.

0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Honored Contributor

It looks like maybe 4.4 was handling it incorrectly.

Looking at the service info, the defaultVisibility of all layers except for "Bikeways" is false, so 4.8 is displaying the layer correctly now.

https://geo.azmag.gov/gismag/rest/services/Test/BikeMap_Test/MapServer?f=pjson 

You could iterate over the sublayers and turn them all on if you'd like

JS Bin - Collaborative JavaScript Debugging 

You could also use the LayerList to manage the visibility. You can see that the LayerList also picked up the correct visibility of the layers.

JS Bin - Collaborative JavaScript Debugging 

Hope that helps, thanks!

View solution in original post

2 Replies
ReneRubalcava
Honored Contributor

It looks like maybe 4.4 was handling it incorrectly.

Looking at the service info, the defaultVisibility of all layers except for "Bikeways" is false, so 4.8 is displaying the layer correctly now.

https://geo.azmag.gov/gismag/rest/services/Test/BikeMap_Test/MapServer?f=pjson 

You could iterate over the sublayers and turn them all on if you'd like

JS Bin - Collaborative JavaScript Debugging 

You could also use the LayerList to manage the visibility. You can see that the LayerList also picked up the correct visibility of the layers.

JS Bin - Collaborative JavaScript Debugging 

Hope that helps, thanks!

JackFairfield
Frequent Contributor

Thanks for the help Rene.  I really appreciate it.

That makes total sense to me.

0 Kudos