<?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 to get selected FeatureLayer in LayerList? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680559#M63439</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All you need to do is using layer.watch to check the visible status&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;featureLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;watch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"visible"&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;val&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;val &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;true&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;alert&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Recreation Layer is visible"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&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;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;alert&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Recreation Layer is invisible"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Here I provide a sample code to show:&lt;/P&gt;&lt;P&gt;&lt;A class="jivelink11" href="https://jsfiddle.net/xeub4Lww/1/" title="https://jsfiddle.net/xeub4Lww/" rel="nofollow noopener noreferrer" target="_blank"&gt;https://jsfiddle.net/xeub4Lww/1/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 04:39:42 GMT</pubDate>
    <dc:creator>YueWu1</dc:creator>
    <dc:date>2021-12-12T04:39:42Z</dc:date>
    <item>
      <title>How to get selected FeatureLayer in LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680558#M63438</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are using JS 4.2 API. &amp;nbsp;There must be some way to determine which FeatureLayer was selected to be visible or not without having to write an Action for each item in the LayerList. &amp;nbsp;Basically, how can I get the FeatureLayer from the LayerList based on action item I chose? &amp;nbsp;I can get the ListItems, but what attribute tells me it is the one to operate on?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Feb 2017 22:50:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680558#M63438</guid>
      <dc:creator>RaymondIrwin</dc:creator>
      <dc:date>2017-02-09T22:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to get selected FeatureLayer in LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680559#M63439</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All you need to do is using layer.watch to check the visible status&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;featureLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;watch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"visible"&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;val&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;val &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;true&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;alert&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Recreation Layer is visible"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&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;else&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&lt;SPAN class="token function"&gt;alert&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Recreation Layer is invisible"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;Here I provide a sample code to show:&lt;/P&gt;&lt;P&gt;&lt;A class="jivelink11" href="https://jsfiddle.net/xeub4Lww/1/" title="https://jsfiddle.net/xeub4Lww/" rel="nofollow noopener noreferrer" target="_blank"&gt;https://jsfiddle.net/xeub4Lww/1/&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:39:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680559#M63439</guid>
      <dc:creator>YueWu1</dc:creator>
      <dc:date>2021-12-12T04:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to get selected FeatureLayer in LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680560#M63440</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you. &amp;nbsp;You are keying off the visibility and the title, but also specifying title as well. &amp;nbsp;What happens if have several layers and several are visible and you don't necessarily know all the names in advance? &amp;nbsp;Suppose we have 50 possible layers and wanted to adjust transparency (a defined action) on any one of those so could see the ones below. &amp;nbsp;That's a whole lot of code and hard values if have to branch for each item.title. &amp;nbsp; Isn't there some property or event that says, "I am the ListItem that you chose?"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2017 01:07:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680560#M63440</guid>
      <dc:creator>RaymondIrwin</dc:creator>
      <dc:date>2017-02-10T01:07:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to get selected FeatureLayer in LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680561#M63441</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;Basically, how can I get the FeatureLayer from the LayerList based on action item I chose? &amp;nbsp;I can get the ListItems, but what attribute tells me it is the one to operate on?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In 4.3 the ListItem will have a `layer` property that indicates the layer associated with the fired action. Not available in 4.2 though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Feb 2017 17:56:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680561#M63441</guid>
      <dc:creator>KristianEkenes</dc:creator>
      <dc:date>2017-02-10T17:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to get selected FeatureLayer in LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680562#M63442</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/105703"&gt;Kristian Ekenes&lt;/A&gt;‌&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been trying to use the ListItem to get the id of the layer that the user just made visible but I haven't been able to get it to work. I'm using API 4.3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you have a little example on how to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I actually made another post:&amp;nbsp;&lt;A href="https://community.esri.com/thread/198097"&gt;LayerList API 4.3 obtain Id of the sublayer on toggle&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you could help me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;Isaac&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Jul 2017 17:47:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680562#M63442</guid>
      <dc:creator>IsaacLañado</dc:creator>
      <dc:date>2017-07-13T17:47:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to get selected FeatureLayer in LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680563#M63443</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Isaac,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I know what you're looking for, but it takes a little extra work than what I described above. In the workflow of my previous comment, I was referring to getting the layer ID when an action is invoked. When toggling layer visibility, the trigger-action event doesn't fire since actions aren't being used. Instead, you'll have to set up a watcher on each list item to watch for the visibility of the item in the layerlist. You can then grab the layerID within the callback of the watcher. I'll take a look at this some more and see if I can post more details on the other thread you mentioned. Hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2017 17:34:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680563#M63443</guid>
      <dc:creator>KristianEkenes</dc:creator>
      <dc:date>2017-07-24T17:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get selected FeatureLayer in LayerList?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680564#M63444</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ki Kristian,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you very much for looking into this. It would help a lot if we could get this working or a little example on how to create the watchers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your time and help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jul 2017 20:42:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-get-selected-featurelayer-in-layerlist/m-p/680564#M63444</guid>
      <dc:creator>IsaacLañado</dc:creator>
      <dc:date>2017-07-24T20:42:51Z</dc:date>
    </item>
  </channel>
</rss>

