<?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 Removing a Feature Layer? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/removing-a-feature-layer/m-p/99517#M9111</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to do this?&amp;nbsp; I can remove layers added as dynamic or tiled map services, but I can't remove layers added as a Feature Layer (unless I use .removeAllLayers, which of course gets rid of everything, which I don't want).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why doesn't .removeLayer work with Feature Layers?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 Jun 2012 18:28:35 GMT</pubDate>
    <dc:creator>BrettGreenfield__DNR_</dc:creator>
    <dc:date>2012-06-05T18:28:35Z</dc:date>
    <item>
      <title>Removing a Feature Layer?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/removing-a-feature-layer/m-p/99517#M9111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a way to do this?&amp;nbsp; I can remove layers added as dynamic or tiled map services, but I can't remove layers added as a Feature Layer (unless I use .removeAllLayers, which of course gets rid of everything, which I don't want).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why doesn't .removeLayer work with Feature Layers?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 18:28:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/removing-a-feature-layer/m-p/99517#M9111</guid>
      <dc:creator>BrettGreenfield__DNR_</dc:creator>
      <dc:date>2012-06-05T18:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a Feature Layer?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/removing-a-feature-layer/m-p/99518#M9112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you post some code that shows how you are trying to remove your feature layer?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use a feature layer that is populated by a web service using a feature collection/layer definition.&amp;nbsp; I keep my featureLayer variable as a global and then am able to use removeLayer(featureLayer) to remove it from the map and re-add it as needed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 Jun 2012 19:12:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/removing-a-feature-layer/m-p/99518#M9112</guid>
      <dc:creator>JenniferGaa</dc:creator>
      <dc:date>2012-06-05T19:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Removing a Feature Layer?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/removing-a-feature-layer/m-p/99519#M9113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply Jennifer - fortunately, I figured it out!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt; var map;
 var oysterLayers;
 
&amp;nbsp;&amp;nbsp;&amp;nbsp; function init() {
&amp;nbsp;&amp;nbsp; var extent = new esri.geometry.Extent({"xmin":409914.00497589994,"ymin":104607.44204058842,"xmax":482562.42004832183,"ymax":141217.9675552771,"spatialReference":{"wkid":26985}})
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map = new esri.Map("map",{extent:extent});
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp; var baseMap = new esri.layers.ArcGISTiledMapServiceLayer("http://www.mdimap.us/ArcGIS/rest/services/ImageryBaseMapsEarthCover/MD.State.MDiMap_Gazetteer83M/MapServer");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(baseMap);
&amp;nbsp;&amp;nbsp; oysterLayers = new esri.layers.FeatureLayer("http://www.mdimap.us/ArcGIS/rest/services/Biota/MD.State.BayOysters/MapServer/0"); 
&amp;nbsp;&amp;nbsp; 
 }
 
 function toggle(form) {
&amp;nbsp; if (form.checkThis.checked) {
&amp;nbsp;&amp;nbsp; map.addLayer(oysterLayers)
&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp; map.removeLayer(oysterLayers)
&amp;nbsp; }
 }&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The layer I was trying to toggle with a checkbox was the one defined by the oysterLayers variable.&amp;nbsp; I had originally defined that variable under the toggle function; for some reason when doing that, I could add the layer via the checkbox, but not remove it.&amp;nbsp; Any idea why that's the case?&amp;nbsp; I'm still quite new to JavaScript so I'm not able to see why that wouldn't work.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:11:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/removing-a-feature-layer/m-p/99519#M9113</guid>
      <dc:creator>BrettGreenfield__DNR_</dc:creator>
      <dc:date>2021-12-11T06:11:26Z</dc:date>
    </item>
  </channel>
</rss>

