<?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 Capture show hide event of layerlist ArcGIS Javascript in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/capture-show-hide-event-of-layerlist-arcgis/m-p/1262304#M80403</link>
    <description>&lt;P&gt;Hello, I have a map in which I have added a feature layer and it shows in the LayerList on the top right corner.&lt;/P&gt;&lt;P&gt;Now what I want is, I want to capture the event whenever I show or hide this layer from the LayerList so that according to this I can do things.&lt;/P&gt;&lt;P&gt;Here is the sample code what I have tried so far.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;script&amp;gt;
        require([
            "esri/config",
            "esri/Map",
            "esri/views/MapView",
            "esri/layers/FeatureLayer",
            "esri/Basemap",
            "esri/Graphic",
            "esri/layers/GraphicsLayer",
            "esri/symbols/PictureMarkerSymbol",
            "esri/layers/support/LabelClass",
            "esri/rest/support/Query",
            "esri/geometry/Point",
            "esri/views/layers/LayerView",
            "esri/rest/locator",
            "esri/geometry/Polygon",
            "esri/symbols/SimpleLineSymbol",
            "esri/symbols/SimpleFillSymbol",
            "esri/widgets/LayerList",
            "esri/widgets/Expand",
        ], (esriConfig, Map, MapView, FeatureLayer, Basemap, Graphic, GraphicsLayer, PictureMarkerSymbol, LabelClass, Query, Point, LayerView, locator, Polygon, SimpleLineSymbol, SimpleFillSymbol, LayerList, Expand) =&amp;gt; {

            esriConfig.apiKey= API_KEY;

            const map = new Map();

            // const map = new Map({
            //     basemap: "arcgis-topographic" // Basemap layer
            // });

            const view = new MapView({
                map: map,
                center: [85.7780685, 25.8560264],
                scale: 1800000,
                container: "viewDiv",
                constraints: {
                    snapToZoom: false
                }
            });

            // District feature layer
            // Add district layer custom layout
            const districtLayerBorderLayout = {
                type: "simple",
                symbol: {
                    type: "simple-line",
                    style: "short-dot",
                    color: "#000000",
                    width: "1px"
                }
            };

            const districtLayerTextLayout = new LabelClass({
                symbol: {
                    type: "text",
                    color: "#ff00ff",
                    font: {
                        size: 10
                    }
                },
                labelExpressionInfo: {
                    expression: "$feature.D_NAME"
                }
            });

            // Add district layer to the mapview
            const districtLayer = new FeatureLayer({
                url: "https://gis.fmiscwrdbihar.gov.in/arcgis/rest/services/GisAtlas/GIS_Atlas_2023/MapServer/22",
                outFields:["*"],
                renderer: districtLayerBorderLayout,
                labelingInfo: [districtLayerTextLayout]
            });
            map.add(districtLayer, 0);

            // layer list widget
            ////////////////////////// Add legend //////////////////////////
            const layerList = new LayerList({
                view: view
            });

            const layerListExpand = new Expand({
                expandIconClass: "esri-icon-layers",
                expandTooltip: "LayerList",
                view: view,
                expanded: false,
                content: layerList,
                group: "expandable-widgets"
            });

            view.ui.add([layerListExpand], "top-right")

        });
    &amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 28 Feb 2023 06:01:10 GMT</pubDate>
    <dc:creator>aggarwalarpit93</dc:creator>
    <dc:date>2023-02-28T06:01:10Z</dc:date>
    <item>
      <title>Capture show hide event of layerlist ArcGIS Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/capture-show-hide-event-of-layerlist-arcgis/m-p/1262304#M80403</link>
      <description>&lt;P&gt;Hello, I have a map in which I have added a feature layer and it shows in the LayerList on the top right corner.&lt;/P&gt;&lt;P&gt;Now what I want is, I want to capture the event whenever I show or hide this layer from the LayerList so that according to this I can do things.&lt;/P&gt;&lt;P&gt;Here is the sample code what I have tried so far.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;&amp;lt;script&amp;gt;
        require([
            "esri/config",
            "esri/Map",
            "esri/views/MapView",
            "esri/layers/FeatureLayer",
            "esri/Basemap",
            "esri/Graphic",
            "esri/layers/GraphicsLayer",
            "esri/symbols/PictureMarkerSymbol",
            "esri/layers/support/LabelClass",
            "esri/rest/support/Query",
            "esri/geometry/Point",
            "esri/views/layers/LayerView",
            "esri/rest/locator",
            "esri/geometry/Polygon",
            "esri/symbols/SimpleLineSymbol",
            "esri/symbols/SimpleFillSymbol",
            "esri/widgets/LayerList",
            "esri/widgets/Expand",
        ], (esriConfig, Map, MapView, FeatureLayer, Basemap, Graphic, GraphicsLayer, PictureMarkerSymbol, LabelClass, Query, Point, LayerView, locator, Polygon, SimpleLineSymbol, SimpleFillSymbol, LayerList, Expand) =&amp;gt; {

            esriConfig.apiKey= API_KEY;

            const map = new Map();

            // const map = new Map({
            //     basemap: "arcgis-topographic" // Basemap layer
            // });

            const view = new MapView({
                map: map,
                center: [85.7780685, 25.8560264],
                scale: 1800000,
                container: "viewDiv",
                constraints: {
                    snapToZoom: false
                }
            });

            // District feature layer
            // Add district layer custom layout
            const districtLayerBorderLayout = {
                type: "simple",
                symbol: {
                    type: "simple-line",
                    style: "short-dot",
                    color: "#000000",
                    width: "1px"
                }
            };

            const districtLayerTextLayout = new LabelClass({
                symbol: {
                    type: "text",
                    color: "#ff00ff",
                    font: {
                        size: 10
                    }
                },
                labelExpressionInfo: {
                    expression: "$feature.D_NAME"
                }
            });

            // Add district layer to the mapview
            const districtLayer = new FeatureLayer({
                url: "https://gis.fmiscwrdbihar.gov.in/arcgis/rest/services/GisAtlas/GIS_Atlas_2023/MapServer/22",
                outFields:["*"],
                renderer: districtLayerBorderLayout,
                labelingInfo: [districtLayerTextLayout]
            });
            map.add(districtLayer, 0);

            // layer list widget
            ////////////////////////// Add legend //////////////////////////
            const layerList = new LayerList({
                view: view
            });

            const layerListExpand = new Expand({
                expandIconClass: "esri-icon-layers",
                expandTooltip: "LayerList",
                view: view,
                expanded: false,
                content: layerList,
                group: "expandable-widgets"
            });

            view.ui.add([layerListExpand], "top-right")

        });
    &amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Feb 2023 06:01:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/capture-show-hide-event-of-layerlist-arcgis/m-p/1262304#M80403</guid>
      <dc:creator>aggarwalarpit93</dc:creator>
      <dc:date>2023-02-28T06:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Capture show hide event of layerlist ArcGIS Javascript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/capture-show-hide-event-of-layerlist-arcgis/m-p/1262417#M80409</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/657951"&gt;@aggarwalarpit93&lt;/a&gt;&amp;nbsp;, thanks for posting.&amp;nbsp; I'd suggest using the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-core-reactiveUtils.html" target="_self"&gt;reactiveUtils&lt;/A&gt; watch method to do this.&amp;nbsp; This would allow you to watch for changes in the layer's visible property and then respond.&amp;nbsp; I modified your original example in this&amp;nbsp;&lt;A href="https://codepen.io/sagewall/pen/abapWPb?editors=0011" target="_self"&gt;codepen&lt;/A&gt;&amp;nbsp;:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;reactiveUtils.watch(
  // getValue function
  () =&amp;gt; districtLayer.visible,
  // callback
  (visible) =&amp;gt; {
    visible ? console.log("The district layer is visible") : console.log("The district layer is not visible")
  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Feb 2023 13:07:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/capture-show-hide-event-of-layerlist-arcgis/m-p/1262417#M80409</guid>
      <dc:creator>Sage_Wall</dc:creator>
      <dc:date>2023-02-28T13:07:37Z</dc:date>
    </item>
  </channel>
</rss>

