<?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: using layer name instead of layer id in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543040#M50553</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm a real newbie and have a web app that embeds an ArcGIS map using the JavaScript API. I used the sample code from the following and have my app working:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you visit the URL above, you'll see it uses layer ids for the default layers to be displayed (i.e., "imageParameters.layerIds = [2];" and "visible = [2];"). I currently have mine set to use layer ids, but I needed more than 1 layer displayed by default, so I currently have: "imageParameters.layerIds = [0,1,20,21,22];" and "visible = [0,1,20,21,22];".&lt;BR /&gt;&lt;BR /&gt;However, over time, the layer order will change because I'll be adding new layers. Therefore, I want to refer to the layers by name, instead of id.&lt;BR /&gt;&lt;BR /&gt;How do I modify the code at the sample URL above to set the default layers to display using layer names, instead of layer ids?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Steve&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For both ArcGISDynamicMapServiceLayer and ArcGISTiledMapServiceLayer, there is a property call layerInfos which is LayerInfo[]. Each element of the array is a object of LayerInfo which has id, name etc properties. You can use it for your purpose. See Javascript API Reference for more detail.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Jan 2011 18:49:44 GMT</pubDate>
    <dc:creator>HemingZhu</dc:creator>
    <dc:date>2011-01-12T18:49:44Z</dc:date>
    <item>
      <title>using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543039#M50552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm a real newbie and have a web app that embeds an ArcGIS map using the JavaScript API. I used the sample code from the following and have my app working:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you visit the URL above, you'll see it uses layer ids for the default layers to be displayed (i.e., "imageParameters.layerIds = [2];" and "visible = [2];"). I currently have mine set to use layer ids, but I needed more than 1 layer displayed by default, so I currently have: "imageParameters.layerIds = [0,1,20,21,22];" and "visible = [0,1,20,21,22];".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, over time, the layer order will change because I'll be adding new layers. Therefore, I want to refer to the layers by name, instead of id.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I modify the code at the sample URL above to set the default layers to display using layer names, instead of layer ids?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jan 2011 16:06:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543039#M50552</guid>
      <dc:creator>SteveSkelton1</dc:creator>
      <dc:date>2011-01-11T16:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543040#M50553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I'm a real newbie and have a web app that embeds an ArcGIS map using the JavaScript API. I used the sample code from the following and have my app working:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_explicitlayerlist.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you visit the URL above, you'll see it uses layer ids for the default layers to be displayed (i.e., "imageParameters.layerIds = [2];" and "visible = [2];"). I currently have mine set to use layer ids, but I needed more than 1 layer displayed by default, so I currently have: "imageParameters.layerIds = [0,1,20,21,22];" and "visible = [0,1,20,21,22];".&lt;BR /&gt;&lt;BR /&gt;However, over time, the layer order will change because I'll be adding new layers. Therefore, I want to refer to the layers by name, instead of id.&lt;BR /&gt;&lt;BR /&gt;How do I modify the code at the sample URL above to set the default layers to display using layer names, instead of layer ids?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Steve&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For both ArcGISDynamicMapServiceLayer and ArcGISTiledMapServiceLayer, there is a property call layerInfos which is LayerInfo[]. Each element of the array is a object of LayerInfo which has id, name etc properties. You can use it for your purpose. See Javascript API Reference for more detail.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jan 2011 18:49:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543040#M50553</guid>
      <dc:creator>HemingZhu</dc:creator>
      <dc:date>2011-01-12T18:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543041#M50554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;For both ArcGISDynamicMapServiceLayer and ArcGISTiledMapServiceLayer, there is a property call layerInfos which is LayerInfo[]. Each element of the array is a object of LayerInfo which has id, name etc properties. You can use it for your purpose. See Javascript API Reference for more detail.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As I said, I'm a newbie. If anyone wants to give me some sample code to modify the code at the URL I listed above to use layer names via LayerInfo, I'd appreciate it. Otherwise, I'm off to see if I can figure it out myself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all the help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 14:06:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543041#M50554</guid>
      <dc:creator>SteveSkelton1</dc:creator>
      <dc:date>2011-01-18T14:06:08Z</dc:date>
    </item>
    <item>
      <title>Re: using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543042#M50555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to modify &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_dynamiclayerlist.html"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_dynamiclayerlist.html&lt;/A&gt;&lt;SPAN&gt; to do what I need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Jan 2011 18:38:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543042#M50555</guid>
      <dc:creator>SteveSkelton1</dc:creator>
      <dc:date>2011-01-18T18:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543043#M50556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Steve - two days before Christmas and I am running down for the year - any chance you could post what you did?&amp;nbsp; I was after exactly the same. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've got to e-write my ArcIMS code next year, and replacing IDs with names was a crucial step in my old IMS stuff - also generously written by someone else!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ACM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Dec 2011 09:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543043#M50556</guid>
      <dc:creator>AdrianMarsden</dc:creator>
      <dc:date>2011-12-23T09:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543044#M50557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples_start.htm&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;Map | Create Layer List&amp;nbsp; (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_dynamiclayerlist.html"&gt;http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jssamples/map_dynamiclayerlist.html&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The sample code above shows you how to loop through and display all layers with checkboxes. This sample should work for you if you want all layers included.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I didn't want some of the layers shown in the layer list. Below is code for my current buildLayerList function. I added an IF statement to capture the layers I wanted included. However, FYI, comparing what I have now to what they have in sample code at link above, it looks like something's a little different from when I first got the sample code from them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function buildLayerList(layer) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var infos = layer.layerInfos, info;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var items = [];&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var i=0, il=infos.length; i&amp;lt;il; i++) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; info = infos&lt;I&gt;;&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (info.name == 'Sample Layer Name #1' || info.name == 'Sample Layer Name #2' || info.name == 'Sample Layer Name #3') {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; visible.push(info.id);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; items&lt;I&gt; = "&amp;lt;input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" + info.id + "'&amp;nbsp; onclick='updateLayerVisibility();' /&amp;gt;&amp;lt;label for='" + info.id + "'&amp;gt;" + info.name + "&amp;lt;/label&amp;gt;";&lt;/I&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.byId("layer_list").innerHTML = items.join(" ");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layer.setVisibleLayers(visible);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(layer);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Dec 2011 11:23:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543044#M50557</guid>
      <dc:creator>SteveSkelton1</dc:creator>
      <dc:date>2011-12-23T11:23:38Z</dc:date>
    </item>
    <item>
      <title>Re: using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543045#M50558</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;many thanks - I'll take a good look at that next year, it seems to be a good starting point&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ACM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Dec 2011 11:30:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543045#M50558</guid>
      <dc:creator>AdrianMarsden</dc:creator>
      <dc:date>2011-12-23T11:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543046#M50559</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have an updated version of this code?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 May 2015 19:24:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543046#M50559</guid>
      <dc:creator>ChrisSergent</dc:creator>
      <dc:date>2015-05-13T19:24:20Z</dc:date>
    </item>
    <item>
      <title>Re: using layer name instead of layer id</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543047#M50560</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; background-color: #ffffff;"&gt;I want the updated version of this code !! Anyone help kindly&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 06:25:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-layer-name-instead-of-layer-id/m-p/543047#M50560</guid>
      <dc:creator>irtizahussain</dc:creator>
      <dc:date>2018-10-17T06:25:01Z</dc:date>
    </item>
  </channel>
</rss>

