<?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: How can I detect when a layer panel has been selected or clicked? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-detect-when-a-layer-panel-has-been/m-p/1337144#M82449</link>
    <description>&lt;P&gt;Thanks, it is what i'm looking for&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2023 22:26:00 GMT</pubDate>
    <dc:creator>mukecz1</dc:creator>
    <dc:date>2023-10-11T22:26:00Z</dc:date>
    <item>
      <title>How can I detect when a layer panel has been selected or clicked?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-detect-when-a-layer-panel-has-been/m-p/1336856#M82435</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, I'm using the LayerList Widget. It seems I can only detect "trigger-action". &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;H&lt;/SPAN&gt;&lt;SPAN&gt;ow can I detect when a layer panel has been selected or clicked without using &lt;/SPAN&gt;&lt;FONT color="#000000"&gt;actionsSections&lt;/FONT&gt;&lt;SPAN&gt;? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I just want to detect the event when I click on the panel header.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 09:19:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-detect-when-a-layer-panel-has-been/m-p/1336856#M82435</guid>
      <dc:creator>mukecz1</dc:creator>
      <dc:date>2023-10-11T09:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I detect when a layer panel has been selected or clicked?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-detect-when-a-layer-panel-has-been/m-p/1336893#M82436</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/552520"&gt;@mukecz1&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for posting your question.&amp;nbsp; You can use &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html" target="_self"&gt;reactiveUtils&lt;/A&gt; to watch for property changes in the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-LayerList.html" target="_self"&gt;LayerList&lt;/A&gt; widget. The API tends to avoid having lots of events in favor of responding to property changes with reactiveUtils.&lt;/P&gt;&lt;P&gt;I wrote this &lt;A href="https://codepen.io/sagewall/pen/oNJVYWx" target="_self"&gt;codepen&lt;/A&gt; that shows how to respond to selection and visibility changes in the LayerList widget, and there are a couple snippets from it below.&lt;/P&gt;&lt;P&gt;You can watch the `selectedItems` property and respond when the collection is modified&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;          // Console log the selected items titles when selectedItems changes
          reactiveUtils.watch(
            () =&amp;gt; layerList.selectedItems.map(item =&amp;gt; item.title),
            (itemTitles) =&amp;gt; itemTitles.forEach((itemTitle) =&amp;gt; {
              console.log(`${itemTitle} (selected)`)
            })
          )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or, if you are interested in when a layers visibility changes&amp;nbsp; you can watch the maps layers collection filtered by visible layers and respond.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;          // Console log the collection of visible layers titles when a layer's visiblity changes
          reactiveUtils.watch(
            () =&amp;gt; view.map.layers.filter(layer =&amp;gt; layer.visible),
            (visibleLayers) =&amp;gt; visibleLayers.forEach((visibleLayer) =&amp;gt; {
              console.log(`${visibleLayer.title} (visible)`)
            })
          )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 12:47:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-detect-when-a-layer-panel-has-been/m-p/1336893#M82436</guid>
      <dc:creator>Sage_Wall</dc:creator>
      <dc:date>2023-10-11T12:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I detect when a layer panel has been selected or clicked?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-detect-when-a-layer-panel-has-been/m-p/1337144#M82449</link>
      <description>&lt;P&gt;Thanks, it is what i'm looking for&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 22:26:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-can-i-detect-when-a-layer-panel-has-been/m-p/1337144#M82449</guid>
      <dc:creator>mukecz1</dc:creator>
      <dc:date>2023-10-11T22:26:00Z</dc:date>
    </item>
  </channel>
</rss>

