<?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 Can a layer URL be swapped? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144890#M13484</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my app I have 3 layers; each layer has an array with 2-3 endpoint URLs associated with it. When the app first loads and I create the layers, I pull the first URL from the layer's associated array, apply display levels, and add the layer to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have an "onError" function that determines which layer failed, pulls the next URL from the layer's URL array, and assigns that URL to the layer. Problem: it seems that the URL can't be switched. Do I have to remove the layer from the map, re-create the layer with the next URL, and add the layer back to the map?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 08 May 2013 19:13:14 GMT</pubDate>
    <dc:creator>TyroneLigon</dc:creator>
    <dc:date>2013-05-08T19:13:14Z</dc:date>
    <item>
      <title>Can a layer URL be swapped?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144890#M13484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my app I have 3 layers; each layer has an array with 2-3 endpoint URLs associated with it. When the app first loads and I create the layers, I pull the first URL from the layer's associated array, apply display levels, and add the layer to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have an "onError" function that determines which layer failed, pulls the next URL from the layer's URL array, and assigns that URL to the layer. Problem: it seems that the URL can't be switched. Do I have to remove the layer from the map, re-create the layer with the next URL, and add the layer back to the map?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 19:13:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144890#M13484</guid>
      <dc:creator>TyroneLigon</dc:creator>
      <dc:date>2013-05-08T19:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can a layer URL be swapped?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144891#M13485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Do I have to remove the layer from the map, re-create the layer with the next URL, and add the layer back to the map?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe that this is the case.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 May 2013 20:19:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144891#M13485</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2013-05-08T20:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Can a layer URL be swapped?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144892#M13486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Final resolution: remove the failing map layer, re-create the layer after getting the next endpoint URL, and add it to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note: if you add a dojo.connect statement to the layer, the statement ceases to exist when you delete the layer; when the layer is re-created and added to the map, you also have to re-create the connect statement. Discovered this little gem when testing what happens when the second endpoint URL also generates an error; lost about 1 1/2 hours trying to figure out why my URL switch code didn't work when more than one URL was invalid.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 May 2013 14:13:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144892#M13486</guid>
      <dc:creator>TyroneLigon</dc:creator>
      <dc:date>2013-05-10T14:13:57Z</dc:date>
    </item>
    <item>
      <title>Re: Can a layer URL be swapped?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144893#M13487</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Note: if you add a dojo.connect statement to the layer, the statement ceases to exist when you delete the layer; when the layer is re-created and added to the map, you also have to re-create the connect statement. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You could attach the connect statement to a variable, so that you could disconnect it explicitly when the layer failed:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
var listener = dojo.connect(layerName, "onError", removeLayer);
function removeLayer() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //disconnect the listener
&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.disconnect(listener);

&amp;nbsp;&amp;nbsp;&amp;nbsp; //code to remove the layer
}
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;my URL switch code didn't work when more than one URL was invalid.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A more pressing question might be why so many of your URLs are failing. Is that something you can solve? It's pretty unusual to need to resort to this layer replacement.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck,&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 07:55:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144893#M13487</guid>
      <dc:creator>StephenLead</dc:creator>
      <dc:date>2021-12-11T07:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Can a layer URL be swapped?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144894#M13488</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Steve,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm writing code to handle situations where the map service is not available; to simulate that scenario, I deliberately misspell at least one of the map service names in the layer's URL array. I've gotten to the point where the error code works fine except for one scenario: the first layer added to the map fails. There's &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/83164"&gt;another ticket&lt;/A&gt;&lt;SPAN&gt; that somewhat addresses this scenario, so I will add to that ticket's thread.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 May 2013 18:03:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/can-a-layer-url-be-swapped/m-p/144894#M13488</guid>
      <dc:creator>TyroneLigon</dc:creator>
      <dc:date>2013-05-13T18:03:49Z</dc:date>
    </item>
  </channel>
</rss>

