<?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: Get layer order within map in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204883#M18988</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, I wondered if that might be the case.&amp;nbsp; I'll experiment with this further next week but I think that hopefully answers it - I'll let you know!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Dec 2014 16:54:35 GMT</pubDate>
    <dc:creator>SimonHodge</dc:creator>
    <dc:date>2014-12-12T16:54:35Z</dc:date>
    <item>
      <title>Get layer order within map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204879#M18984</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;Does anyone know if there is a way of getting a layers current index / order in the map?&amp;nbsp; The map has a reorder function where you can pass a layer and an index, but in order to know where I want to place the layer, I need to know the index of the layer I'm moving it above or below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It occurred to me it might be possible to keep track of the order all layers are added to the map, for example by listing for layer-add type events.&amp;nbsp; I'm not sure how reliable that would be though and hoped there was a built in mechanism.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note: I'm not wanting to re-order sub layers within a map service, as per the reorder example here: &lt;A href="https://developers.arcgis.com/javascript/jssamples/layers_dynamic_reorder.html" title="https://developers.arcgis.com/javascript/jssamples/layers_dynamic_reorder.html"&gt;Reorder layers in map service | ArcGIS API for JavaScript&lt;/A&gt;&amp;nbsp;&amp;nbsp; I want to actually re-order the map service layer itself, relative to other map service layers loaded in the map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 16:20:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204879#M18984</guid>
      <dc:creator>SimonHodge</dc:creator>
      <dc:date>2014-12-12T16:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer order within map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204880#M18985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use "map.layerIds" to get the listing of layers in your map. This &lt;A href="http://jsbin.com/zekituviqu/1/edit?html,console,output"&gt;JSBin&lt;/A&gt; show that, also showing the basemap layers that are included. These layers will change if you switch basemaps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 16:31:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204880#M18985</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2014-12-12T16:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer order within map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204881#M18986</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ken,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for that - I had just come to a similar conclusion: that the layerIds are (I think) returned in their index order (or rather reverse order).&amp;nbsp; i.e. it will be the order the layers were added to the map by default, but the top most layer for repositioning is 0.&amp;nbsp; If a layer has been re-ordered then it will appear in a different index in the layerIds array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, there is still something I'm not certain of.&amp;nbsp; There is also a graphicslayerIds property which returns the ids of all the graphics layers and feature layers: these layers aren't included in the layerIds array.&amp;nbsp; So say you had 5 dynamic map services and 5 feature layers on a map:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;layerIds returns [dynamicA, dynamicB, dynamicC, dynamicD, dynamicE]&lt;/P&gt;&lt;P&gt;graphicsLayerIds returns [featureA, featureB, featureC, featureD, featureE]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How would you know what index to set dynamicC to to move it above dynamic?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 16:46:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204881#M18986</guid>
      <dc:creator>SimonHodge</dc:creator>
      <dc:date>2014-12-12T16:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer order within map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204882#M18987</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This shouldn't be an issue. A &lt;A href="https://developers.arcgis.com/javascript/jsapi/graphicslayer-amd.htmlhttp://"&gt;graphics layer&lt;/A&gt; will always be placed above dynamic or tiled layers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 16:51:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204882#M18987</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2014-12-12T16:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer order within map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204883#M18988</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ah, I wondered if that might be the case.&amp;nbsp; I'll experiment with this further next week but I think that hopefully answers it - I'll let you know!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Dec 2014 16:54:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204883#M18988</guid>
      <dc:creator>SimonHodge</dc:creator>
      <dc:date>2014-12-12T16:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer order within map</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204884#M18989</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help - I've got it working.&amp;nbsp; To correct something I said earlier, the bottom most layer is 0, not the top most.&amp;nbsp; This makes the maths easier as you pointed out: the graphics and feature layers are always on top so don't skew the ids at all.&amp;nbsp; It's simply a matter of getting the index in the array of the layer you want to move and adding / subtracting.&amp;nbsp; It's therefore really easy to create up / down buttons that adjust the position of the selected layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Dec 2014 12:36:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-layer-order-within-map/m-p/204884#M18989</guid>
      <dc:creator>SimonHodge</dc:creator>
      <dc:date>2014-12-15T12:36:54Z</dc:date>
    </item>
  </channel>
</rss>

