<?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 Hiding Multiple Feature Layers in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hiding-multiple-feature-layers/m-p/365000#M33846</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to use layer.hide(); for multiple layers in a single function? I need to hide several layers at once, and the order they're in seems to be affecting its function. I have this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp; bikeLayer.hide();
&amp;nbsp;&amp;nbsp; mopedLayer.hide();
&amp;nbsp;&amp;nbsp; atmLayer.hide();
&amp;nbsp;&amp;nbsp; recLayer.hide();
&amp;nbsp;&amp;nbsp; foodLayer.hide();
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;as part of a larger function. if bikeLayer is turned on, I can hide it. if only atmLayer is on, it won't shut off, with the error that bikeLayer is not defined. How can I do this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Oct 2011 20:51:11 GMT</pubDate>
    <dc:creator>BenReilly</dc:creator>
    <dc:date>2011-10-25T20:51:11Z</dc:date>
    <item>
      <title>Hiding Multiple Feature Layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hiding-multiple-feature-layers/m-p/365000#M33846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to use layer.hide(); for multiple layers in a single function? I need to hide several layers at once, and the order they're in seems to be affecting its function. I have this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp; bikeLayer.hide();
&amp;nbsp;&amp;nbsp; mopedLayer.hide();
&amp;nbsp;&amp;nbsp; atmLayer.hide();
&amp;nbsp;&amp;nbsp; recLayer.hide();
&amp;nbsp;&amp;nbsp; foodLayer.hide();
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;as part of a larger function. if bikeLayer is turned on, I can hide it. if only atmLayer is on, it won't shut off, with the error that bikeLayer is not defined. How can I do this?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2011 20:51:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hiding-multiple-feature-layers/m-p/365000#M33846</guid>
      <dc:creator>BenReilly</dc:creator>
      <dc:date>2011-10-25T20:51:11Z</dc:date>
    </item>
    <item>
      <title>Re: Hiding Multiple Feature Layers</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hiding-multiple-feature-layers/m-p/365001#M33847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is there a way to use layer.hide(); for multiple layers in a single function?... if only atmLayer is on, it won't shut off, with the error that bikeLayer is not defined&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Ben,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could define an array of layers, and add each layer to the array when it is defined. Then iterate through the array and switch off each layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
//define the array of layers - add each layer as it's created
var mapLayers = [];
mapLayers.add(bikeLayer);
mapLayers.add(atmLayer); //etc

//To switch off the layers
for (var i = 0; i &amp;lt; mapLayers.length - 1; i++) {
&amp;nbsp; mapLayers&lt;I&gt;.hide()
}
&lt;/I&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/hiding-multiple-feature-layers/m-p/365001#M33847</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2021-12-11T16:58:56Z</dc:date>
    </item>
  </channel>
</rss>

