<?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 Group Layer open in Layer List upon map load in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284063#M81000</link>
    <description>&lt;P&gt;I'm working with a single group layer in the layer list widget. By default, the group layer is visible, but collapsed upon map load. For ease of use for the end user, I would like the group layer to be open/expanded when the map loads. I believe I can achieve this by changing the CSS for the widget.&amp;nbsp; I've added this block of code to the style and have tried different things, but haven't been able to get the group layer to be open upon map load. Any assistance is appreciated.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;.esri-layer-list__child-toggle .esri-layer-list__child-toggle-icon--opened,
  .esri-layer-list__child-toggle .esri-layer-list__child-toggle-icon--closed-rtl,
  .esri-layer-list__child-toggle--open .esri-layer-list__child-toggle-icon--closed {
    display: none;
  }
  .esri-layer-list__child-toggle--open .esri-layer-list__child-toggle-icon--opened {
    display: block;
  }&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 28 Apr 2023 19:29:27 GMT</pubDate>
    <dc:creator>AshleyPeters</dc:creator>
    <dc:date>2023-04-28T19:29:27Z</dc:date>
    <item>
      <title>Group Layer open in Layer List upon map load</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284063#M81000</link>
      <description>&lt;P&gt;I'm working with a single group layer in the layer list widget. By default, the group layer is visible, but collapsed upon map load. For ease of use for the end user, I would like the group layer to be open/expanded when the map loads. I believe I can achieve this by changing the CSS for the widget.&amp;nbsp; I've added this block of code to the style and have tried different things, but haven't been able to get the group layer to be open upon map load. Any assistance is appreciated.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;.esri-layer-list__child-toggle .esri-layer-list__child-toggle-icon--opened,
  .esri-layer-list__child-toggle .esri-layer-list__child-toggle-icon--closed-rtl,
  .esri-layer-list__child-toggle--open .esri-layer-list__child-toggle-icon--closed {
    display: none;
  }
  .esri-layer-list__child-toggle--open .esri-layer-list__child-toggle-icon--opened {
    display: block;
  }&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 28 Apr 2023 19:29:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284063#M81000</guid>
      <dc:creator>AshleyPeters</dc:creator>
      <dc:date>2023-04-28T19:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Group Layer open in Layer List upon map load</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284066#M81001</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You don't have to do this via CSS. You can set the&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction" target="_self"&gt; LayerList.listItemCreatedFunction&lt;/A&gt;&amp;nbsp;to expand the grouplayer on start. The code snippet in the SDK doc shows this and the following is the code.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const layerList = new LayerList({
  view: view,
  // executes for each ListItem in the LayerList
  listItemCreatedFunction: defineActions
});

// Add widget to the top right corner of the view
view.ui.add(layerList, "top-right");

function defineActions(event) {
  const item = event.item;
  if (item.layer.type === "group"){
    item.open = true;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;-Undral&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 19:55:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284066#M81001</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-04-28T19:55:17Z</dc:date>
    </item>
    <item>
      <title>Re: Group Layer open in Layer List upon map load</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284067#M81002</link>
      <description>&lt;P&gt;&lt;EM&gt;Edit: Beaten by Undral!&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;You don't need to use CSS for this. You can use the&amp;nbsp;listItemCreatedFunction to iterate through the items in the LayerList and determine which ones you want open by default.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Demo&lt;/P&gt;&lt;P&gt;&lt;A href="https://codepen.io/odoe/pen/PoyKwyw?editors=100" target="_blank" rel="noopener"&gt;https://codepen.io/odoe/pen/PoyKwyw?editors=100&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 19:58:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284067#M81002</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2023-04-28T19:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: Group Layer open in Layer List upon map load</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284071#M81004</link>
      <description>&lt;P&gt;Hi Ashley, you can achieve this by using the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html#listItemCreatedFunction" target="_self"&gt;listItemCreatedFunction&lt;/A&gt;&amp;nbsp;property of the LayerList.&amp;nbsp; Then set open to true for the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList-ListItem.html" target="_self"&gt;ListItem&lt;/A&gt;&amp;nbsp;for the layer you want expanded.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;let layerList = new LayerList({
  view: view,
  // executes for each ListItem in the LayerList
  listItemCreatedFunction: function (event) {

    // The event object contains properties of the
    // layer in the LayerList widget.

    let item = event.item;

    if (item.title === "US Demographics") {
      // open the list item in the LayerList
      item.open = true;
      // change the title to something more descriptive
      item.title = "Population by county";
      // set an action for zooming to the full extent of the layer
      item.actionsSections = [[{
        title: "Go to full extent",
        className: "esri-icon-zoom-out-fixed",
        id: "full-extent"
      }]];
    }
  }
});&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 28 Apr 2023 20:06:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284071#M81004</guid>
      <dc:creator>Justin_Greco</dc:creator>
      <dc:date>2023-04-28T20:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Group Layer open in Layer List upon map load</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284078#M81006</link>
      <description>&lt;P&gt;Wow, thank you all! I looked at actions, but didn't see anything that made sense for a solution. But, that worked like a charm. Always good to learn something new!&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 20:38:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/group-layer-open-in-layer-list-upon-map-load/m-p/1284078#M81006</guid>
      <dc:creator>AshleyPeters</dc:creator>
      <dc:date>2023-04-28T20:38:21Z</dc:date>
    </item>
  </channel>
</rss>

