<?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 How do I add multiple layers to the LayerList? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350856#M32498</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to add multiple layers to the LayerList dijit (using 3.21). I tried to add each layer to an array as it was added to the map and then reference the array when making the LayerList, but this left out all of the sublayers. here is my code:&lt;/P&gt;&lt;P&gt;var layerArray = new Array();&lt;BR /&gt; var tempLayer = new ArcGISDynamicMapServiceLayer(&lt;BR /&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fsampleserver1.arcgisonline.com%2FArcGIS%2Frest%2Fservices%2FDemographics%2FESRI_Population_World%2FMapServer" rel="nofollow" target="_blank"&gt;https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer&lt;/A&gt;&lt;SPAN&gt;");&lt;/SPAN&gt;&lt;BR /&gt; layerArray.push(map.addLayer(tempLayer));&lt;/P&gt;&lt;P&gt;.....repeated with different layers.......&lt;/P&gt;&lt;P&gt;//layerlist widget initialization&lt;BR /&gt; var layerListWidget = new LayerList({&lt;BR /&gt; map: map,&lt;BR /&gt; layers: layerArray&lt;BR /&gt; }, "layerList");&lt;BR /&gt; layerListWidget.startup();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to add all of the layers (and sublayers) to the layerList Dijit programmatically?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 24 Aug 2017 14:26:26 GMT</pubDate>
    <dc:creator>GregSalvador</dc:creator>
    <dc:date>2017-08-24T14:26:26Z</dc:date>
    <item>
      <title>How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350856#M32498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to add multiple layers to the LayerList dijit (using 3.21). I tried to add each layer to an array as it was added to the map and then reference the array when making the LayerList, but this left out all of the sublayers. here is my code:&lt;/P&gt;&lt;P&gt;var layerArray = new Array();&lt;BR /&gt; var tempLayer = new ArcGISDynamicMapServiceLayer(&lt;BR /&gt;&lt;SPAN&gt; "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fsampleserver1.arcgisonline.com%2FArcGIS%2Frest%2Fservices%2FDemographics%2FESRI_Population_World%2FMapServer" rel="nofollow" target="_blank"&gt;https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Population_World/MapServer&lt;/A&gt;&lt;SPAN&gt;");&lt;/SPAN&gt;&lt;BR /&gt; layerArray.push(map.addLayer(tempLayer));&lt;/P&gt;&lt;P&gt;.....repeated with different layers.......&lt;/P&gt;&lt;P&gt;//layerlist widget initialization&lt;BR /&gt; var layerListWidget = new LayerList({&lt;BR /&gt; map: map,&lt;BR /&gt; layers: layerArray&lt;BR /&gt; }, "layerList");&lt;BR /&gt; layerListWidget.startup();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to add all of the layers (and sublayers) to the layerList Dijit programmatically?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Aug 2017 14:26:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350856#M32498</guid>
      <dc:creator>GregSalvador</dc:creator>
      <dc:date>2017-08-24T14:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350857#M32499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; You will see in the widget documentation that if you do not add a layers property in the LayerList widget constructor then it will display all layers that are in the map. You do need to wait for the layers to be added to the map before creating the LayerList widget though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Aug 2017 15:37:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350857#M32499</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-08-24T15:37:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350858#M32500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Robert. I don't know how I missed this tidbit, but thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Aug 2017 16:07:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350858#M32500</guid>
      <dc:creator>GregSalvador</dc:creator>
      <dc:date>2017-08-24T16:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350859#M32501</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So I have another question: how do i remove a layer from the layerList? I noticed that one of the layers added is the basemap, and I don't want users to be able to toggle it on and off. I didnt see a remove function, so do I have to instead define all of the layers that I want in the list and omit the basemap Layer?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Aug 2017 17:04:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350859#M32501</guid>
      <dc:creator>GregSalvador</dc:creator>
      <dc:date>2017-08-24T17:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350860#M32502</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Do I have to instead define all of the layers that I want in the list and omit the basemap Layer?&lt;/BLOCKQUOTE&gt;&lt;P&gt;Correct&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Our you could wait for the load event on the widget and manipulate the layers array.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Aug 2017 17:17:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350860#M32502</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-08-24T17:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350861#M32503</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi again.&lt;BR /&gt;I am trying to wait for the load event on the widget and the manipulate the layers array. I seem to be doing something wrong, as i get a browser error saying "TypeError: c is null". The problem seems to be with my on("load") statement, but all of the examples I have seen seem to do it similarly. I checked, and my require "dojo/on" and the function order is the same, and I've called the on("load") function after I have declared the LayerList. Is there a step i am missing somewhere? Here is my code:&lt;BR /&gt;require([&lt;BR /&gt;"esri/map",&lt;BR /&gt;"esri/arcgis/utils",&lt;BR /&gt;"esri/layers/ArcGISDynamicMapServiceLayer",&lt;BR /&gt;"esri/dijit/LayerList",&lt;BR /&gt;"esri/dijit/BasemapGallery",&lt;BR /&gt;"dijit/layout/BorderContainer",&lt;BR /&gt;"dijit/layout/ContentPane",&lt;BR /&gt;"dojo/parser",&lt;BR /&gt;"dojo/on",&lt;BR /&gt;"dojo/domReady!"&lt;BR /&gt;], function (Map, arcgisUtils, ArcGISDynamicMapServiceLayer, LayerList, BasemapGallery, parser, on) {&lt;BR /&gt;...declaring layers and map object.....&lt;/P&gt;&lt;P&gt;//layerlist widget initialization&lt;BR /&gt;var layerListWidget = new LayerList({&lt;BR /&gt;map: map,&lt;BR /&gt;}, "layerList");&lt;BR /&gt;layerListWidget.startup();&lt;BR /&gt;on(layerListWidget, "load", function (item) {&lt;BR /&gt;item.layers.reverse();&lt;BR /&gt;item.layers.pop();&lt;BR /&gt;item.layers.reverse();&lt;BR /&gt;});&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 13:58:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350861#M32503</guid>
      <dc:creator>GregSalvador</dc:creator>
      <dc:date>2017-08-25T13:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350862#M32504</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Greg,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;Your requires and corresponding vars are out of order.&lt;/P&gt;&lt;P&gt;You have:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;require&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/map"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/arcgis/utils"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/layers/ArcGISDynamicMapServiceLayer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/dijit/LayerList"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/dijit/BasemapGallery"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dijit/layout/BorderContainer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dijit/layout/ContentPane"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dojo/parser"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dojo/on"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dojo/domReady!"&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcgisUtils&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ArcGISDynamicMapServiceLayer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; LayerList&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; BasemapGallery&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; parser&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; on&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Should be:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="token function"&gt;require&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/map"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/arcgis/utils"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/layers/ArcGISDynamicMapServiceLayer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/dijit/LayerList"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"esri/dijit/BasemapGallery"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dojo/parser"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dojo/on"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dijit/layout/BorderContainer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dijit/layout/ContentPane"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
&lt;SPAN class="string token"&gt;"dojo/domReady!"&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; arcgisUtils&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ArcGISDynamicMapServiceLayer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; LayerList&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; BasemapGallery&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; parser&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; on&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:30:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350862#M32504</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-11T16:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350863#M32505</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ok, I get it, i think. All of the requires with a corresponding variable have to be first, followed the the requires that don't have a variable? do the requires with a variable need to be in any specific order(as long as they stay synced up)?&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 14:26:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350863#M32505</guid>
      <dc:creator>GregSalvador</dc:creator>
      <dc:date>2017-08-25T14:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add multiple layers to the LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350864#M32506</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As long as they stay synced up (listed in the same order) then you are fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Aug 2017 14:29:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-do-i-add-multiple-layers-to-the-layerlist/m-p/350864#M32506</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-08-25T14:29:40Z</dc:date>
    </item>
  </channel>
</rss>

