Select to view content in your preferred language

How to control sublayer visibility in 4.7 MapImageLayer

1147
2
Jump to solution
06-13-2018 02:57 PM
KrisKaplan1
Occasional Contributor

Is it possible to control the sublayer visibility of a map service layer that does not support dynamic sublayers in 4.7?

In 3.24 this was possible with the LAYER_OPTION_SHOW in the ImageParameters passed to ArcGISDynamicMapServiceLayer.  See this example.

In 4.7 the matrix indicates MapImageLayer is the eqivalent.  But specifying more than one sublayer in the 'sublayers' property causes it to require dynamic layer support from the layer source.  See this example.  This sample emits an error in the console indicating the service 'doesn't support dynamic layers, which is required to be able to change the sublayer's order, rendering, labeling or source'.  But I am not attempting to change the order, rendering, labeling, or source.  Just layer visibility.  Is it possible to show multiple sublayers without requiring dynamic layers?

Kris

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Kris,

   This is a crazy not documented fact but your sub layer id have to be in descending order.

        const layer = new MapImageLayer({
          url: 'https://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer',
          sublayers: [
            {id: 28, visible: true},
            {id: 27, visible: true}
          ]
        });

Make this change to your 4.7 sample and it works fine.

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Kris,

   This is a crazy not documented fact but your sub layer id have to be in descending order.

        const layer = new MapImageLayer({
          url: 'https://hazards.fema.gov/gis/nfhl/rest/services/public/NFHL/MapServer',
          sublayers: [
            {id: 28, visible: true},
            {id: 27, visible: true}
          ]
        });

Make this change to your 4.7 sample and it works fine.

KrisKaplan1
Occasional Contributor

Thanks a lot.  I spent a lot of time trying to preserve the order, and never tried reversing it.

Kris

0 Kudos