<?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: Turn off  a sublayer when button click on TOC -agsjs in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turn-off-a-sublayer-when-button-click-on-toc-agsjs/m-p/423000#M38899</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the button to turn off the sublayer the same way you use to turn it on, with the setVisibleLayers method of the layer. You just have to make sure that the sublayer is not in the array used in that method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do this, you would first obtain the list of visible layers using the layer visibleLayers method. Next, use Dojo's&lt;A href="http://dojotoolkit.org/reference-guide/1.9/dojo/_base/array.html#indexof"&gt; indexOf&lt;/A&gt; (this gets around any browser incompatibilities with the normal array.indexOf) to determine whether that visibleLayers array contains a specific sublayer, then use &lt;A href="http://stackoverflow.com/questions/5767325/remove-specific-element-from-an-array"&gt;splice&lt;/A&gt; to remove it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 21 Aug 2014 15:29:35 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2014-08-21T15:29:35Z</dc:date>
    <item>
      <title>Turn off  a sublayer when button click on TOC -agsjs</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turn-off-a-sublayer-when-button-click-on-toc-agsjs/m-p/422999#M38898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I download TOC here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109" title="https://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109"&gt;https://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;I want to create a button like the sample one able to turn on/off a layer. &lt;/P&gt;&lt;P&gt;I only able to turn on a sublayer using setVisibleLayers&amp;nbsp; method here when a button is clicked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;on(dom.byId("SetVisibleLayersProgramatically"),'click', function(evt){&lt;/P&gt;&lt;P&gt;Dynlayer.setVisibleLayers([11]);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But how do you turn off the same sublayer when another button is clicked?&amp;nbsp; I don't want to use toc.findTOCNode( Dynlayer, 11).hide().&amp;nbsp; It will remove the layer.&amp;nbsp; I would to uncheck the layer instead of remove the layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way, simple way to do this task?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jul 2014 21:29:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turn-off-a-sublayer-when-button-click-on-toc-agsjs/m-p/422999#M38898</guid>
      <dc:creator>MayJeff</dc:creator>
      <dc:date>2014-07-23T21:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Turn off  a sublayer when button click on TOC -agsjs</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turn-off-a-sublayer-when-button-click-on-toc-agsjs/m-p/423000#M38899</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the button to turn off the sublayer the same way you use to turn it on, with the setVisibleLayers method of the layer. You just have to make sure that the sublayer is not in the array used in that method.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To do this, you would first obtain the list of visible layers using the layer visibleLayers method. Next, use Dojo's&lt;A href="http://dojotoolkit.org/reference-guide/1.9/dojo/_base/array.html#indexof"&gt; indexOf&lt;/A&gt; (this gets around any browser incompatibilities with the normal array.indexOf) to determine whether that visibleLayers array contains a specific sublayer, then use &lt;A href="http://stackoverflow.com/questions/5767325/remove-specific-element-from-an-array"&gt;splice&lt;/A&gt; to remove it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Aug 2014 15:29:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/turn-off-a-sublayer-when-button-click-on-toc-agsjs/m-p/423000#M38899</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2014-08-21T15:29:35Z</dc:date>
    </item>
  </channel>
</rss>

