AnsweredAssumed Answered

How to use dynamic layers in js api 4.4

Question asked by roemhildtg on Aug 17, 2017
Latest reply on Aug 17, 2017 by roemhildtg

I'm confused on how I can use dynamic layers in the 4.4 api. I have a group of layers published from arcmap like this:

By default, all of the group layers are off, some of the child layers are on, and nothing is visible until the user toggles a group layer on. (this is how it works in 3.x).


In 4.4, I set up some layer like this: 

                id: 'assets',
                url: `${url}/internal/assets/MapServer`,
                // sublayers: [{
                //     id: 12,
                //     visible: true
                // }, {
                //     id: 13,
                //     visible: true
                // }],
                popupTemplate: {
                    title: 'cid: {cid}'


When the map loads, all of the child layers that are visible are displayed. The map looks crazy busy. 

So just to test what happens I uncomment the above code to show only sublayer 12. 


This works, only sublayer 12 is shown:

Now if I uncomment both sublayers 12 and 13 from the block above, it stops working. I get no image from the server. I checked the network logs.


In the version with no sublayers, the network image request looks like this:



With one sublayer:



With two sublayers: 



My questions are: 

  • Why does providing no sublayers display the layer incorrectly (ie ignoring group layer visibility)?
  • Why do the parameters change from layers to dynamicLayers when switching from one sublayer to two sublayers? - a similar problem is observed here: