<?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: Add functionality to toggle FeatureLayer on/off in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385128#M83704</link>
    <description>&lt;P&gt;I'm not fully following your code. It looks like you cut some parts out. But if you have three feature layers, it would be easiest to track them in three separate pieces of state, so they can be toggled as needed.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Feb 2024 20:36:59 GMT</pubDate>
    <dc:creator>JeffreyThompson2</dc:creator>
    <dc:date>2024-02-21T20:36:59Z</dc:date>
    <item>
      <title>Add functionality to toggle FeatureLayer on/off</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385071#M83700</link>
      <description>&lt;P&gt;Javascript 1.5, ArcGIS Experience Builder 1.13&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I would like to add functionality (buttons?) to my Javascript (REACT) that allows toggling FeatureLayers on/off.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Snippet of my code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { React, AllWidgetProps } from "jimu-core";
import { JimuMapView, JimuMapViewComponent } from 'jimu-arcgis'
import FeatureLayer from "@arcgis/core/layers/FeatureLayer";
import Graphic from "@arcgis/core/Graphic";
import { Button, Icon } from 'jimu-ui'; // import ui components
  const { useRef, useState } = React
  export default function Widget (props: AllWidgetProps&amp;lt;any&amp;gt;) {
    const [mapView, setMapView] = useState&amp;lt;JimuMapView&amp;gt;()
    const [mapView, setMapView] = useState&amp;lt;JimuMapView&amp;gt;()
    const fileLayer = useRef&amp;lt;__esri.Layer[]&amp;gt;([])
// Location Points are loaded in fileLayer (there are 3 layers)
// fileLayer is used to to create ringPolys (geometryEngine) which in turn are used to create Graphics (three of them)
            const ringGraphics: Graphic[] = []
            for (let index = 0; index &amp;lt; ringPolys.length; index++) {
              const ringPoly = ringPolys[index];
              const ringGraphic = new Graphic({
                geometry: ringPoly,
                symbol: bufferSymbol,
                attributes: {
                  ObjectId: index,
                  "name": "Graphic" + index
                }
              })
              console.log(ringGraphic)
              ringGraphics.push(ringGraphic)
            }//end for

// Graphics are used to create FeatureLayers (featLayer)
    mapView.view.map.add(featLayer)
    return (
        &amp;lt;div&amp;gt;
        {
          props.useMapWidgetIds &amp;amp;&amp;amp;
          props.useMapWidgetIds.length === 1 &amp;amp;&amp;amp; (
            &amp;lt;JimuMapViewComponent
              useMapWidgetId={props.useMapWidgetIds?.[0]}
              onActiveViewChange={(jmv: JimuMapView) =&amp;gt; {setMapView(jmv)} }
            /&amp;gt;
          )
        }
        &amp;lt;/div&amp;gt;
     )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm pretty sure that whatever I get working, it's going to reside in the return function. If easier, I'd be ok with toggling the Graphics instead.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 19:31:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385071#M83700</guid>
      <dc:creator>MikeSousa</dc:creator>
      <dc:date>2024-02-21T19:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Add functionality to toggle FeatureLayer on/off</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385085#M83701</link>
      <description>&lt;P&gt;This post includes an example of how to add/remove layers within an Experience Builder widget.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/experience-builder-tips-and-tricks/react-for-experience-builder-developer-edition/ba-p/1346222" target="_blank"&gt;https://community.esri.com/t5/experience-builder-tips-and-tricks/react-for-experience-builder-developer-edition/ba-p/1346222&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 19:46:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385085#M83701</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2024-02-21T19:46:18Z</dc:date>
    </item>
    <item>
      <title>Re: Add functionality to toggle FeatureLayer on/off</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385098#M83702</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks Jeffrey&lt;/P&gt;&lt;P&gt;I failed to mention that I had seen this but was still confused as to how to remove/add any 1 of the three layers available (might be more layers in the future).&lt;/P&gt;&lt;P&gt;Thanks...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 19:55:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385098#M83702</guid>
      <dc:creator>MikeSousa</dc:creator>
      <dc:date>2024-02-21T19:55:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add functionality to toggle FeatureLayer on/off</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385128#M83704</link>
      <description>&lt;P&gt;I'm not fully following your code. It looks like you cut some parts out. But if you have three feature layers, it would be easiest to track them in three separate pieces of state, so they can be toggled as needed.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Feb 2024 20:36:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/add-functionality-to-toggle-featurelayer-on-off/m-p/1385128#M83704</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2024-02-21T20:36:59Z</dc:date>
    </item>
  </channel>
</rss>

