<?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: Exception after remove and add a layer to web map / javascript in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85330#M7730</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Piterson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I have never had a need to add and remove a layer back and forth like that so I am not sure what is going wrong. I would always remove and recreate the layer personally.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 21 Dec 2016 20:30:09 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2016-12-21T20:30:09Z</dc:date>
    <item>
      <title>Exception after remove and add a layer to web map / javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85327#M7727</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Simple question: What is the correct way to remove a layer (&lt;SPAN style="color: #636363; background-color: #fefefe;"&gt;ArcGISDynamicMapServiceLayer&lt;/SPAN&gt;)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We do constantly add and remove layers to/from a map object. We noticed that after remove and add there is an exception&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #ff6600;"&gt;Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff6600;"&gt;&lt;SPAN&gt; at Object._onLoadHandler (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fjs.arcgis.com%2F3.17%2Finit.js%3A1857%3A295" rel="nofollow" target="_blank"&gt;https://js.arcgis.com/3.17/init.js:1857:295&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff6600;"&gt;&lt;SPAN&gt; at HTMLImageElement.&amp;lt;anonymous&amp;gt; (&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fjs.arcgis.com%2F3.17%2Finit.js%3A63%3A154" rel="nofollow" target="_blank"&gt;https://js.arcgis.com/3.17/init.js:63:154&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="color: #000000;"&gt;What is wrong? What is the meaning?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2016 05:58:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85327#M7727</guid>
      <dc:creator>PitersonPaulgek</dc:creator>
      <dc:date>2016-12-21T05:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: Exception after remove and add a layer to web map / javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85328#M7728</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Piterson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;It is just map.removeLayer(layer); then layer = null; if you want to completely destroy that layer class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2016 13:03:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85328#M7728</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-12-21T13:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Exception after remove and add a layer to web map / javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85329#M7729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert,&lt;/P&gt;&lt;P&gt;Thank you for your response,&lt;/P&gt;&lt;P&gt;We do not wont to destroy the layer - we will add it next time.&lt;/P&gt;&lt;P&gt;I understand that possible way is to make a layer visible/invisible, but what is wrong to remove/add layer?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe the variable used with map.removeLayer(globalVariable)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To be specific, it works like:&lt;/P&gt;&lt;P&gt;1)we create new layer&lt;/P&gt;&lt;P&gt;layerGlobalVariable1 = new&amp;nbsp;ArcGISDynamicMapServiceLayer(......)&lt;/P&gt;&lt;P&gt;2)we put to array&lt;/P&gt;&lt;P&gt;dictionaryLayers[layerName1] =&amp;nbsp;&lt;SPAN&gt;layerGlobalVariable1 &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;3)we add to map&lt;/P&gt;&lt;P&gt;globalVariableCurrentLayer =&amp;nbsp;&lt;SPAN&gt;dictionaryLayers[layerName1] &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;app.map.addLayer(&lt;SPAN&gt;globalVariableCurrentLayer &lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;4)&amp;nbsp;app.map.removeLayer(globalVariableCurrentLayer)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;5)&amp;nbsp;app.map.addLayer(&lt;SPAN&gt;globalVariableCurrentLayer&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;the exception is here, BUT not exactly on the row map.addLayer();&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2016 20:14:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85329#M7729</guid>
      <dc:creator>PitersonPaulgek</dc:creator>
      <dc:date>2016-12-21T20:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exception after remove and add a layer to web map / javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85330#M7730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Piterson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I have never had a need to add and remove a layer back and forth like that so I am not sure what is going wrong. I would always remove and recreate the layer personally.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2016 20:30:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85330#M7730</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-12-21T20:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exception after remove and add a layer to web map / javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85331#M7731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Robert,&lt;/P&gt;&lt;P&gt;I see.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I noticed that we create the array as Object:&lt;/P&gt;&lt;P&gt;dictionaryLayers= {};&lt;/P&gt;&lt;P&gt;And after that put layers:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;dictionaryLayers[layerName1] =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="background-color: #ffffff; border: 0px;"&gt;layerGlobalVariable1;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 21 Dec 2016 23:51:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85331#M7731</guid>
      <dc:creator>PitersonPaulgek</dc:creator>
      <dc:date>2016-12-21T23:51:50Z</dc:date>
    </item>
    <item>
      <title>Re: Exception after remove and add a layer to web map / javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85332#M7732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Piterson,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; There does not seem to be anything wrong with what you are doing there. But I would re consider your workflow. Why is it necessary to try and hold on to a layer variable after it is removed from the map? This seems to me like a poor use of memory when you can destroy and reconstruct the layer as needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 22 Dec 2016 14:41:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/exception-after-remove-and-add-a-layer-to-web-map/m-p/85332#M7732</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-12-22T14:41:34Z</dc:date>
    </item>
  </channel>
</rss>

