Setting sublayer visibility

1969
4
Jump to solution
10-23-2013 03:18 PM
by Anonymous User
Not applicable
Greetings!  I have a dynamic map service in my application and I would like to programmatically set sublayer visibility on it much as they do in the Table of Contents widget.  Can someone suggest how this might be done?  Seems like it should be pretty straight forward but I wasn't finding anything in the widget reference offhand ...
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Bob,

  The sample is a little involved (complex) but the jist of it is simply specifying an array of LayerIDs that you want to be visible. If you have a service with 20 sub layers and you want layer 2, 7, 10, 18 to be visible then you just provide and array of those layer ids to the ArcGISDynamicMapServiceLayer.visibleLayers property.

ArcGISDynamicMapServiceLayer.visibleLayers = [2,7,10,18];

View solution in original post

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus
Bob,

   Here is a link to an API sample to do just that. You can also look at the API docs for the ArcGISDynamicMapServiceLayer.visibleLayers property

https://developers.arcgis.com/en/flex/sample-code/dynamic-map-layers-on-off.htm
https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/layers/ArcGISDynamicMapServiceLayer...
0 Kudos
by Anonymous User
Not applicable
Robert -

    Thanks for the quick response!  It seems from the code snippet you pointed me to that it really comes down to the built-in functionality of <samples:LayerTOC width="210" height="100%" mapLayer="{myDynamicService}"/> - correct me if I'm wrong ... I've got to head out of town shortly but will try and implement this upon my return next week and let you know how it goes ...

    I also wanted to give you the heads up that we've been having issues with your Identify Widget.  For the most part it works awesomely but we're having an issue with one or two layers that show up in the results with no details (see image) and everything in the config file seems to check out but still no results.  I'll start a separate thread on that when I return as well (my image doesn't seem to want to upload right now) ...

   Thanks again!

- Bob
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Bob,

  The sample is a little involved (complex) but the jist of it is simply specifying an array of LayerIDs that you want to be visible. If you have a service with 20 sub layers and you want layer 2, 7, 10, 18 to be visible then you just provide and array of those layer ids to the ArcGISDynamicMapServiceLayer.visibleLayers property.

ArcGISDynamicMapServiceLayer.visibleLayers = [2,7,10,18];
0 Kudos
by Anonymous User
Not applicable
Robert -

    Thank you for the code snippet - that really helped clarify the matter and guide me toward coding a working solution! Consider this matter closed but I am going to start a new thread that pertains to your Identify Widget so please be on the lookout for that - hopefully I'll be able to upload the screen shot I've got and hopefully I'll be able to explain the matter so that you can understand what's happening and even more hopefully you'll have seen this issue before and know what causes it!  Thanks again for help with this matter though ...

~ Bob
0 Kudos