Select to view content in your preferred language

Is it possible to exclude sublayers in ArcGISDynamicMapServiceLayer?

4155
10
Jump to solution
07-30-2015 12:45 PM
RobertKirkwood
Frequent Contributor

I want to exclude several of the sublayers in a ArcGISDynamicMapServiceLayer in the table of contents (TOC). IS this possible and if so where does the happen?

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Take a look at this post, which gives an example on how to hide a sub layer dynamically. You can also hide them when the TOC is initially built. It looks like this is possible using a 10.0 server, also.

View solution in original post

10 Replies
StevenGraf1
Frequent Contributor

Haven't tested with TOC widget., but I believe you would use ImageParameters.

ImageParameters | API Reference | ArcGIS API for JavaScript

Here is a sample:

Layer definitions on a dynamic map service | ArcGIS API for JavaScript

Instead of

imageParameters.layerOption = ImageParameters.LAYER_OPTION_SHOW

you would use

imageParameters.layerOption = ImageParameters.LAYER_OPTION_EXCLUDE

-Steven

RobertKirkwood
Frequent Contributor

Steve,

I did try that. However, the sublayers still show up in the Table of Contents. I think that is for display in the map.

0 Kudos
KenBuja
MVP Esteemed Contributor

Take a look at this post, which gives an example on how to hide a sub layer dynamically. You can also hide them when the TOC is initially built. It looks like this is possible using a 10.0 server, also.

RobertKirkwood
Frequent Contributor

Ken,

That is fantastic! Exactly what i was looking for. Thank you!

0 Kudos
KenBuja
MVP Esteemed Contributor

One note of caution. If you have sub layers within a group layer, you have to include the group layer in the layer ids. You'll get some unexpected behavior if the group layer is excluded.

RobertKirkwood
Frequent Contributor

Ken,

I am just noticing that now. One of the layers still draws even when using the imageParameters in conjunction with the other code for the TOC.

0 Kudos
RobertKirkwood
Frequent Contributor

The problem is that one of the sublayers is checked on. I can make it so that its hidden using the imageParameters and hide it from the TOC, but when i turn on another layer it becomes visible. This isnt my service so i cant modify it on the backend. How would i uncheck it by default?

0 Kudos
KenBuja
MVP Esteemed Contributor

Use the setVisibleLayers method on the layer to specify which sublayers are initially visible.

RobertKirkwood
Frequent Contributor

Oh yeah! i forgot about that. Thanks again.

0 Kudos