ArcGISDynamicMapServiceLayer: unwanted layers included in render

3187
12
Jump to solution
03-06-2017 06:41 AM
YohanBienvenue
Occasional Contributor II

I have an issue where the image render returned by the MapServer does not seem to correspond to the list of visibleLayers specified in the ArcGISDynamicMapServiceLayer. It seems all child layers of a group layer are rendered, whether they are included in the list of visibleLayers or not.

 

ArcGIS API for JavaScript 3.19

ArcGIS Server 10.3.1

Here is an example of a group layer 256 with child layers 257 to 270

 

Screenshot-1

 

Using a layers widget binded to the list of visibleLayers of the ArcGISDynamicMapServiceLayer, if I check one of the child layer, this is export request sent by the API:

 

Screenshot-2

Screenshot-3

You can see that only 256 and 270 are included in the layers parameter of the export request, yet the MapServer will render ALL sublayers 257 to 270.

Is this the default behaviour of the MapServer??

If so, how do I work around this?

I'm thinking maybe I could manually remove group layers in the list of visibleLayers of the ArcGISDynamicMapServiceLayer, but that could create issues with the layers widget, where the group layer would be unchecked too (since it's binded to it), which is not what we want.

I see the export request (Export Map (Operation) ) layers parameter also include an "exclude" option. Is there a way I could exclude all unchecked layers using a setting or option in the ArcGIS JavaScript API? Otherwise how would I do this?

 

Thanks

EDIT:

Here is a more obvious example with an infrastructure group layer:

 


Only child layer 168 is included in the list

But it renders them all:

0 Kudos
12 Replies
YohanBienvenue
Occasional Contributor II

Thanks Ken, yeah I'll definitely make a few adjustments. Would be cleaner to just build a list of group layers once, and then  use that list as a parameter to array.filter the list of visibleLayers to display. Now that I was able to hotfix this issue quickly, I'll be able to polish it a little.

Kind of an unrelated question but how the heck did you format your code in geonet? The code tool does nothing for me, seems broken. Maybe it just doesn't work with Chrome I'm not sure. What browser are you using?

0 Kudos
KenBuja
MVP Esteemed Contributor

I usually use Firefox, but for this reply, I'll use Chrome.

This is the code I'll insert

To do this, I click on the "Expand toolbar" button

Then I click the "Syntax highlighter" under "More"

Note that this isn't available when you reply to a message from the Inbox.

0 Kudos
YohanBienvenue
Occasional Contributor II

Awesome thanks, I can finally use this properly format code.

I just edited my answer with this formatting, and replaced the original code with the better code version I was talking about too.

0 Kudos