<?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: set the order of layer based on id in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1245376#M79772</link>
    <description>&lt;P&gt;The &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id" target="_self"&gt;documentation&lt;/A&gt; indicates that layers must have unique IDs, so going against that would give unpredictable results.&amp;nbsp; I would recommend adjusting your application so layers have unique IDs.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jan 2023 18:11:05 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2023-01-04T18:11:05Z</dc:date>
    <item>
      <title>set the order of layer based on id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1242317#M79670</link>
      <description>&lt;P&gt;How can we&amp;nbsp;set the order of layer based on id. I have tried providing an index while adding the layers but it does not seem to work and also it would be error prone because multiple layers will be getting added through out the app&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 13:13:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1242317#M79670</guid>
      <dc:creator>DivyaArora</dc:creator>
      <dc:date>2022-12-19T13:13:47Z</dc:date>
    </item>
    <item>
      <title>Re: set the order of layer based on id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1242401#M79672</link>
      <description>&lt;P&gt;Assuming you have an array of layer IDs that are sorted in the order you want, and also with the lowest layer at index 0, it seems to me that you could add a function like this and call it as needed (e.g. after adding a layer, etc):&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function resetLayerOrder(map, sortedLayerIDs) {
	var mapLayerIndex = 0;

	sortedLayerIDs.forEach(function(layerID) {
		var layer = map.findLayerById(layerID);

		if (layer)
			map.reorder(layer, mapLayerIndex++);
	});
}&lt;/LI-CODE&gt;&lt;P&gt;(This also assumes you're working with version 4.x of the API; see also &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#reorder" target="_self"&gt;Map.reorder&lt;/A&gt;.)&lt;/P&gt;</description>
      <pubDate>Mon, 19 Dec 2022 16:49:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1242401#M79672</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2022-12-19T16:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: set the order of layer based on id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1244743#M79755</link>
      <description>&lt;P&gt;This seems to be working. But there is a scenario if there are multiple layers with the same id, then it orders the layer in the sequence they were added. For ex: We have set the ordering as :&amp;nbsp; [graphiclayer, imagelayer] and we have 2&amp;nbsp; layers with a graphic added on it and 1 layer with an image. Suppose we add a graphic , then an image and then again a graphic. In this case, the last graphic gets added on the top instead of bottom.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any fix for such scenario ?&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jan 2023 09:18:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1244743#M79755</guid>
      <dc:creator>DivyaArora</dc:creator>
      <dc:date>2023-01-02T09:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: set the order of layer based on id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1245376#M79772</link>
      <description>&lt;P&gt;The &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#id" target="_self"&gt;documentation&lt;/A&gt; indicates that layers must have unique IDs, so going against that would give unpredictable results.&amp;nbsp; I would recommend adjusting your application so layers have unique IDs.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jan 2023 18:11:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1245376#M79772</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-01-04T18:11:05Z</dc:date>
    </item>
    <item>
      <title>Re: set the order of layer based on id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1246361#M79815</link>
      <description>&lt;P&gt;Thanks for the reply. Could you please confirm if there is any other parameter on the basis of which layer ordering can be done ? Any "order" property or something like that which different layer can share&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 07:47:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1246361#M79815</guid>
      <dc:creator>DivyaArora</dc:creator>
      <dc:date>2023-01-09T07:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: set the order of layer based on id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1246534#M79821</link>
      <description>&lt;P&gt;No, there aren't any layer properties native to the API that support layer ordering.&amp;nbsp; That's not to say you can't simply assign one though.&amp;nbsp; For example:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var layer1 = new MapImageLayer({url:"someURL"});
layer1.myLayerOrder = 1;

var layer2 = new MapImageLayer({url:"someOtherURL"});
layer2.myLayerOrder = 2;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You would just need to ensure you assign that custom property for all the layers in your application.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 17:45:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/set-the-order-of-layer-based-on-id/m-p/1246534#M79821</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-01-09T17:45:11Z</dc:date>
    </item>
  </channel>
</rss>

