<?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: How to Dynamically Check on/off a service layer? in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865060#M5592</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tim: Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Jan 2019 19:57:21 GMT</pubDate>
    <dc:creator>ShaningYu</dc:creator>
    <dc:date>2019-01-10T19:57:21Z</dc:date>
    <item>
      <title>How to Dynamically Check on/off a service layer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865054#M5586</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt;"&gt;In my JavaScript App, there are 5 Group layers, each of which contains 4-5 sub-layers, are loaded from an ArcGIS server.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11pt;"&gt;In debugging, I check the Object&amp;nbsp; this.map, but I don't know how to loop the service layers, e.g. &lt;SPAN style="font-size: 11pt;"&gt;How to Dynamically Check a service layer is checked on/off.&amp;nbsp; Thanks if you can help.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Jan 2019 14:31:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865054#M5586</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2019-01-08T14:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Check on/off a service layer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865055#M5587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The documentation for the JavaScript API provides an example for looping through the layers in the map:&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/jsapi/map-amd.html#layerids" title="https://developers.arcgis.com/javascript/3/jsapi/map-amd.html#layerids"&gt;Map | API Reference | ArcGIS API for JavaScript 3.27&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2019 16:30:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865055#M5587</guid>
      <dc:creator>TimMcGee1</dc:creator>
      <dc:date>2019-01-09T16:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Check on/off a service layer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865056#M5588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tim: Thanks for your response.&amp;nbsp; I can access to the layer.&amp;nbsp; But I can't go to the next level.&amp;nbsp; For instance, in my App, there are 2 map service layers.&amp;nbsp; The layer0 is the basemap from ESRI, the other one contains 2 dozens of layers.&amp;nbsp; How can a sublayer be accessed?&amp;nbsp; E.g.&lt;/P&gt;&lt;P&gt;var sLyr = this.map.getLayer( ???);&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;P&gt;var _layer = this.map.getLayer( this.maplayerId[1];&lt;/P&gt;&lt;P&gt;for (var i = 0; i &amp;lt; _layer.layerInfos.length; i++) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; var lyr = this.map.getLayer( ???);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;Thanks if you can provide additional help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2019 19:26:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865056#M5588</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2019-01-09T19:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Check on/off a service layer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865057#M5589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like you would want to use the `layerInfos` array, the `visibleLayers` array and the `setVisibleLayers` method of a Dynamic MapService layer to access the sub layers, and affect their visibility :&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html" title="https://developers.arcgis.com/javascript/3/jsapi/arcgisdynamicmapservicelayer-amd.html"&gt;ArcGISDynamicMapServiceLayer | API Reference | ArcGIS API for JavaScript 3.27&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2019 20:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865057#M5589</guid>
      <dc:creator>TimMcGee1</dc:creator>
      <dc:date>2019-01-09T20:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Check on/off a service layer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865058#M5590</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From &lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/sample-code/layers-mapimagelayer-sublayers/index.html" title="https://developers.arcgis.com/javascript/latest/sample-code/layers-mapimagelayer-sublayers/index.html"&gt;MapImageLayer - Toggle sublayer visibility | ArcGIS API for JavaScript 4.10&lt;/A&gt; , I know it can use&amp;nbsp; &lt;CODE class=""&gt;&lt;SPAN class=""&gt;sublayers&lt;/SPAN&gt; in V4.1.&amp;nbsp; However for the V3.2x, I am still not able to do something like that dynamically check on/off a layer&amp;nbsp;using JS code.&amp;nbsp; Could you provide a sample or some detail?&amp;nbsp; Thanks.&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2019 13:03:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865058#M5590</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2019-01-10T13:03:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Check on/off a service layer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865059#M5591</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The API docs that I linked has sample code on how to use "setVisibleLayers". Here's a few other comments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;visibleLayers‍&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// is an array of ids of the sub layers that are currently visible.,&lt;/SPAN&gt;


lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;setVisibleLayers&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;2&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;3&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;// Sets the sub layers with ids 1, 2 and 3 as the only visible layers.&lt;/SPAN&gt;


lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;setVisibleLayers&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//Sets all layers as not visible.&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:44:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865059#M5591</guid>
      <dc:creator>TimMcGee1</dc:creator>
      <dc:date>2021-12-12T10:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Check on/off a service layer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865060#M5592</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tim: Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:57:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865060#M5592</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2019-01-10T19:57:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to Dynamically Check on/off a service layer?</title>
      <link>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865061#M5593</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tim:  I posted a thread at https://community.esri.com/message/825059-how-to-hide-a-map-service-layer.  I reviewed cmv docs but found no solution.  Could you provide me your hint for the solution?  Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jan 2019 20:24:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/how-to-dynamically-check-on-off-a-service-layer/m-p/865061#M5593</guid>
      <dc:creator>ShaningYu</dc:creator>
      <dc:date>2019-01-15T20:24:48Z</dc:date>
    </item>
  </channel>
</rss>

