<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: problem setting visibility of nested layer in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-visibility-of-nested-layer/m-p/139956#M3508</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;STRONG&gt;&lt;STRONG&gt;QUESTION NUMBER 1: ANY IDEA WHY IT'S STILL BEING DRAWN ON THE MAP???&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;If a group layer is in the list of 'VisibleLayers', all sublayers of this group layer will be visible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;With you example, setting the visibleLayers to {0, 4} is enough to see all layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;STRONG&gt;&lt;STRONG&gt;QUESTION NUMBER 2: ANY IDEA WHY THE GROUP LAYERS ARE BEING OMITTED???&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The group layers are being omitted otherwise all sublayers would be visible (consequence of first question answer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This breaks some of our other code downstream that looks at the VisibleLayers property to determine if a specific sublayer is actually visible or not.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the use case? For any non group layer, the VisibleLayers property should give you the current layer visibility.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Apr 2011 11:56:10 GMT</pubDate>
    <dc:creator>DominiqueBroux</dc:creator>
    <dc:date>2011-04-26T11:56:10Z</dc:date>
    <item>
      <title>problem setting visibility of nested layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-visibility-of-nested-layer/m-p/139955#M3507</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to change the visibility of one of the sublayers in a dynamic map service layer.&amp;nbsp; This is basically set up as a way to override the DefaultVisibility for specific sublayers.&amp;nbsp; The sublayer in question is a couple of layers down in the hierarchy.&amp;nbsp; Even though it's not in the agsDynamicMapServiceLayer.VisibleLayers list, it's still being drawn.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Using the 2.1.0.446 build of the ArcGIS Silverlight API&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dynamic Map Service hierarchy looks something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer&amp;nbsp; Name/Hierarchy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[0]&amp;nbsp; A&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[1]&amp;nbsp;&amp;nbsp; A.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[2]&amp;nbsp;&amp;nbsp; A.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[3]&amp;nbsp;&amp;nbsp; A.3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[4]&amp;nbsp; B&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[5]&amp;nbsp;&amp;nbsp; B.1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[6]&amp;nbsp;&amp;nbsp;&amp;nbsp; B.1.a&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[7]&amp;nbsp;&amp;nbsp; B.2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[8]&amp;nbsp;&amp;nbsp;&amp;nbsp; B.2.a&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Want to make sublayer ???B.1.a??? hidden in initial display (DefaultVisibility is true for that layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All of the following work is done in the Initialized event handler for the ArcGISDynamicMapServiceLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;agsDynamicMapServiceLayer.VisibleLayers is null initially&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Build list of id???s that want to make visible:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;List&amp;lt;int&amp;gt; visibleLayers:&amp;nbsp; 0,1,2,3,4,7,8&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Set into VisibleLayers property:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;agsDynamicMapServiceLayer.VisibleLayers = visibleLayers.ToArray();&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The "B.1.a" layer (6) that is *NOT* present in the agsDynamicMapServiceLayer.VisibleLayers list is still being displayed!?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;QUESTION NUMBER 1:&amp;nbsp; ANY IDEA WHY IT'S STILL BEING DRAWN ON THE MAP???&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I tried using SetVisibility() to turn on/off each layer as appropriate:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;// now turn on only those that we're interested in seeing...&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for ( int i = 0; i &amp;lt; agsDynamicMapServiceLayer.Layers.Count(); i++ )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if ( visibleLayers.Contains( agsDynamicMapServiceLayer.Layers&lt;I&gt;.ID ) )&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; agsDynamicMapServiceLayer.SetLayerVisibility( agsDynamicMapServiceLayer.Layers&lt;I&gt;.ID, true );&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; agsDynamicMapServiceLayer.SetLayerVisibility( agsDynamicMapServiceLayer.Layers&lt;I&gt;.ID, false );&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The map layers are now properly displayed - layer "B.1.a" is NOT rendered on the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HOWEVER, if I look at the VisibleLayers, it only includes the feature layers.&amp;nbsp; None of the group layers are included.&amp;nbsp; This breaks some of our other code downstream that looks at the VisibleLayers property to determine if a specific sublayer is actually visible or not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;QUESTION NUMBER 2:&amp;nbsp; ANY IDEA WHY THE GROUP LAYERS ARE BEING OMITTED???&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;QUESTION NUMBER 3:&amp;nbsp; ANY SUGGESTIONS FOR MORE THINGS TO TRY???&lt;BR /&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gary&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Apr 2011 20:59:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-visibility-of-nested-layer/m-p/139955#M3507</guid>
      <dc:creator>GarySinner</dc:creator>
      <dc:date>2011-04-25T20:59:46Z</dc:date>
    </item>
    <item>
      <title>Re: problem setting visibility of nested layer</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-visibility-of-nested-layer/m-p/139956#M3508</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;STRONG&gt;&lt;STRONG&gt;QUESTION NUMBER 1: ANY IDEA WHY IT'S STILL BEING DRAWN ON THE MAP???&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;If a group layer is in the list of 'VisibleLayers', all sublayers of this group layer will be visible.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;With you example, setting the visibleLayers to {0, 4} is enough to see all layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;STRONG&gt;&lt;STRONG&gt;QUESTION NUMBER 2: ANY IDEA WHY THE GROUP LAYERS ARE BEING OMITTED???&lt;/STRONG&gt;&lt;/STRONG&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The group layers are being omitted otherwise all sublayers would be visible (consequence of first question answer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;This breaks some of our other code downstream that looks at the VisibleLayers property to determine if a specific sublayer is actually visible or not.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;What is the use case? For any non group layer, the VisibleLayers property should give you the current layer visibility.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2011 11:56:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/problem-setting-visibility-of-nested-layer/m-p/139956#M3508</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2011-04-26T11:56:10Z</dc:date>
    </item>
  </channel>
</rss>

