<?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: Adding additional layer list actions to layer list with legend example in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1319442#M82000</link>
    <description>&lt;P&gt;The solutions provided are specific to the samples, because that's how your original request was framed.&amp;nbsp; If you copy and paste the code into the samples, you'll see the solutions do work, and do add an opacity slider into the layer list along with the legend.&lt;/P&gt;&lt;P&gt;I can't tell why it doesn't work in your application, because I can't access it or its source code.&amp;nbsp; Perhaps since the code I've provided is specific to the samples, maybe you included the condition that restricts the modifications to a layer with the title "Census Tracts" (line 24 in both snippets).&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2023 02:03:53 GMT</pubDate>
    <dc:creator>JoelBennett</dc:creator>
    <dc:date>2023-08-17T02:03:53Z</dc:date>
    <item>
      <title>Adding additional layer list actions to layer list with legend example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1316431#M81881</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Was hoping someone can show me how to add the opacity slider to a layer list with legend.&lt;/P&gt;&lt;P&gt;I am essentially trying to combine these two examples. preferably adding action items to the layer list with legend example.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-layerlist-legend" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-layerlist-legend&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-layerlist-actions" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-layerlist-actions&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 14:34:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1316431#M81881</guid>
      <dc:creator>Key</dc:creator>
      <dc:date>2023-08-08T14:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding additional layer list actions to layer list with legend example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1316692#M81889</link>
      <description>&lt;P&gt;In the&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=widgets-layerlist-legend" target="_self"&gt;Add a Legend to LayerList&lt;/A&gt; sample, you can add an opacity slider by changing the contents of the script tag beginning on line 32 to the following:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      require(["esri/WebMap", "esri/views/MapView", "esri/widgets/LayerList", "esri/widgets/Slider"], (
        WebMap,
        MapView,
        LayerList,
        Slider
      ) =&amp;gt; {
        const map = new WebMap({
          portalItem: {
            id: "d5dda743788a4b0688fe48f43ae7beb9"
          }
        });

        // Add the map to a MapView
        const view = new MapView({
          container: "viewDiv",
          map: map
        });

        async function defineActions(event) {
          const item = event.item;

          await item.layer.when();

          if (item.title === "Census Tracts") {
            const slider = new Slider({
              min: 0,
              max: 1,
              precision: 2,
              values: [1],
              visibleElements: {
                labels: true,
                rangeLabels: true
              }
            });

            item.panel = {
              content: ["legend",slider],
              open: true,
              className: "esri-icon-sliders-horizontal",
              title: "Layer Info"
            };

            slider.on("thumb-drag", (event) =&amp;gt; {
              const { value } = event;
              item.layer.opacity = value;
            });
          }
        }

        // Add a legend instance to the panel of a
        // ListItem in a LayerList instance
        const layerList = new LayerList({
          view: view,
          listItemCreatedFunction: defineActions
        });

        view.ui.add(layerList, "top-right");
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 23:33:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1316692#M81889</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-08-08T23:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Adding additional layer list actions to layer list with legend example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1318311#M81972</link>
      <description>&lt;P&gt;Thank you for taking a look!&lt;/P&gt;&lt;P&gt;Your code appears to add the opacity slider but removes the legend items. Below is the code snippet I am using to add the legend to layer list. I'm not sure how to add the slider event to the existing event.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;       // create a layerlist and expand widget and add to the view
        const layerList = new LayerList({
            view: view,
            listItemCreatedFunction: (event) =&amp;gt; {
                const item = event.item;
                if (item.layer.type != "group") {
                    // don't show legend twice
                    item.panel = {
                        content: "legend",
                        open: false
                    };
                }
            }
        });
        const llExpand = new Expand({
            view: view,
            content: layerList,
            expanded: false
        });
        view.ui.add(llExpand, {
            position: "top-left",
            index: 0
        });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 13:46:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1318311#M81972</guid>
      <dc:creator>Key</dc:creator>
      <dc:date>2023-08-14T13:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Adding additional layer list actions to layer list with legend example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1318419#M81975</link>
      <description>&lt;P&gt;If by "legend items" you mean "action items", then perhaps this is what you're looking for:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      require(["esri/WebMap", "esri/views/MapView", "esri/widgets/LayerList", "esri/widgets/Slider"], (
        WebMap,
        MapView,
        LayerList,
        Slider
      ) =&amp;gt; {
        const map = new WebMap({
          portalItem: {
            id: "d5dda743788a4b0688fe48f43ae7beb9"
          }
        });

        // Add the map to a MapView
        const view = new MapView({
          container: "viewDiv",
          map: map
        });

        async function defineActions(event) {
          const item = event.item;

          await item.layer.when();

          if (item.title === "Census Tracts") {
            const slider = new Slider({
              min: 0,
              max: 1,
              precision: 2,
              values: [1],
              visibleElements: {
                labels: true,
                rangeLabels: true
              }
            });

            item.panel = {
              content: ["legend",slider],
              open: true,
              className: "esri-icon-sliders-horizontal",
              title: "Layer Info"
            };

            slider.on("thumb-drag", (event) =&amp;gt; {
              const { value } = event;
              item.layer.opacity = value;
            });

            item.actionsSections = [
              [
                {
                  title: "Go to full extent",
                  className: "esri-icon-zoom-out-fixed",
                  id: "full-extent"
                },
                {
                  title: "Layer information",
                  className: "esri-icon-description",
                  id: "information"
                }
              ],
              [
                {
                  title: "Increase opacity",
                  className: "esri-icon-up",
                  id: "increase-opacity"
                },
                {
                  title: "Decrease opacity",
                  className: "esri-icon-down",
                  id: "decrease-opacity"
                }
              ]
            ];
          }
        }

        // Add a legend instance to the panel of a
        // ListItem in a LayerList instance
        const layerList = new LayerList({
          view: view,
          listItemCreatedFunction: defineActions
        });

          layerList.on("trigger-action", (event) =&amp;gt; {
            // The layer visible in the view at the time of the trigger.
            const visibleLayer = event.item.layer;

            // Capture the action id.
            const id = event.action.id;

            if (id === "full-extent") {
              // if the full-extent action is triggered then navigate
              // to the full extent of the visible layer
              view.goTo(visibleLayer.fullExtent).catch((error) =&amp;gt; {
                if (error.name != "AbortError") {
                  console.error(error);
                }
              });
            } else if (id === "information") {
              // if the information action is triggered, then
              // open the item details page of the service layer
              window.open(visibleLayer.url);
            } else if (id === "increase-opacity") {
              // if the increase-opacity action is triggered, then
              // increase the opacity of the GroupLayer by 0.25

              if (visibleLayer.opacity &amp;lt; 1) {
                visibleLayer.opacity += 0.25;
              }
            } else if (id === "decrease-opacity") {
              // if the decrease-opacity action is triggered, then
              // decrease the opacity of the GroupLayer by 0.25

              if (visibleLayer.opacity &amp;gt; 0) {
                visibleLayer.opacity -= 0.25;
              }
            }
          });

        view.ui.add(layerList, "top-right");
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2023 18:04:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1318419#M81975</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-08-14T18:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: Adding additional layer list actions to layer list with legend example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1318800#M81979</link>
      <description>&lt;P&gt;Thanks for taking another look. If I use the code above it removes the legend within the layer list.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2023-08-15 121353.png" style="width: 276px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/78126i7CA75659B72545C0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2023-08-15 121353.png" alt="Screenshot 2023-08-15 121353.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Aug 2023 17:16:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1318800#M81979</guid>
      <dc:creator>Key</dc:creator>
      <dc:date>2023-08-15T17:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding additional layer list actions to layer list with legend example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1319442#M82000</link>
      <description>&lt;P&gt;The solutions provided are specific to the samples, because that's how your original request was framed.&amp;nbsp; If you copy and paste the code into the samples, you'll see the solutions do work, and do add an opacity slider into the layer list along with the legend.&lt;/P&gt;&lt;P&gt;I can't tell why it doesn't work in your application, because I can't access it or its source code.&amp;nbsp; Perhaps since the code I've provided is specific to the samples, maybe you included the condition that restricts the modifications to a layer with the title "Census Tracts" (line 24 in both snippets).&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 02:03:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1319442#M82000</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2023-08-17T02:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Adding additional layer list actions to layer list with legend example</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1321238#M82060</link>
      <description>&lt;P&gt;Joel,&lt;/P&gt;&lt;P&gt;I got it to work. I feel goofy it didn't come to me earlier. Thank you for your time on this. Below is the solution, I just need to add this snippet&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;        // create a layerlist and expand widget and add to the view
        async function defineActions(event) {
          const item = event.item;

          await item.layer.when();

            if (item.layer.type != "group") {
                // don't show legend twice
                item.panel = {
                    content: "legend",
                    open: false
                };
                }

            if (item.title === "Imagery") {
            const slider = new Slider({
                min: 0,
                max: 1,
                precision: 2,
                values: [1],
                visibleElements: {
                labels: true,
                rangeLabels: true
                }
            });&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 22 Aug 2023 16:57:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/adding-additional-layer-list-actions-to-layer-list/m-p/1321238#M82060</guid>
      <dc:creator>Key</dc:creator>
      <dc:date>2023-08-22T16:57:56Z</dc:date>
    </item>
  </channel>
</rss>

