<?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 Remove Layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-layer/m-p/548684#M51073</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a very simple question. How do I simply remove a layer with a switch function? My below function adds the layer twoYear to the map but doesn't remove the sixMonth.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp; switch (layerSwitchValue) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; case "6Month":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp; case "2year":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayers([twoYear]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.removeLayers([sixMonth]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Jan 2012 20:34:07 GMT</pubDate>
    <dc:creator>deleted-user-K_IRAXrpGKsG</dc:creator>
    <dc:date>2012-01-11T20:34:07Z</dc:date>
    <item>
      <title>Remove Layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-layer/m-p/548684#M51073</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a very simple question. How do I simply remove a layer with a switch function? My below function adds the layer twoYear to the map but doesn't remove the sixMonth.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp; switch (layerSwitchValue) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; case "6Month":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; break;
&amp;nbsp;&amp;nbsp;&amp;nbsp; case "2year":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayers([twoYear]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.removeLayers([sixMonth]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 20:34:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-layer/m-p/548684#M51073</guid>
      <dc:creator>deleted-user-K_IRAXrpGKsG</dc:creator>
      <dc:date>2012-01-11T20:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: Remove Layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-layer/m-p/548685#M51074</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As far as I can see, there isn't a removeLayer&lt;/SPAN&gt;&lt;STRONG&gt;s&lt;/STRONG&gt;&lt;SPAN&gt;() option (to remove an array of layers) on the map object. Instead, there is a removeLayer() option (to remove a single layer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So you could iterate through each layer on the map to find the correct layer. You can iterate through all of the tiled/dynamic layers using &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#layerIds"&gt;map.layerIds&lt;/A&gt;&lt;SPAN&gt; and through all of the feature layers using &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#graphicsLayerIds"&gt;map.graphicsLayerIds&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you'd found the correct layer, you can remove it using &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#removeLayer"&gt;map.removeLayer(layer)&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Jan 2012 22:02:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-layer/m-p/548685#M51074</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2012-01-11T22:02:39Z</dc:date>
    </item>
  </channel>
</rss>

