<?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: Filter hard coded feature layer in React in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515823#M85219</link>
    <description>&lt;P&gt;It is already in the sample. You have to wait for &lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515733#M85217" target="_self"&gt;MapView.whenLayerView&lt;/A&gt; to resolve after you add the layer in your addLayerHandler function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2024 21:21:41 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2024-08-06T21:21:41Z</dc:date>
    <item>
      <title>Filter hard coded feature layer in React</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1510931#M85126</link>
      <description>&lt;P&gt;I am new to custom widget development for experience builder and Javascript. I would like to filter a hard coded feature layer based on a field. I have studied the code at&amp;nbsp;&lt;A href="https://developers.arcgis.com/experience-builder/sample-code/widgets/filter-feature-layer/" target="_blank"&gt;https://developers.arcgis.com/experience-builder/sample-code/widgets/filter-feature-layer/&lt;/A&gt;&amp;nbsp;but it's relying on a feature layer set by the user. In my case, I am not getting any input from the user. I would like to filter the feature layer after it's added to the map on the click of a button.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6522"&gt;@JoelBennett&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/7384"&gt;@ReneRubalcava&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/14934"&gt;@SageWall&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/400217"&gt;@LaurenBoyd&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/677423"&gt;@JeffreyThompson2&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/180"&gt;@AndyGup&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/115266"&gt;@AnneFitz&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/169842"&gt;@Noah-Sager&lt;/a&gt;&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/327152"&gt;@MatthewDriscoll&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Jul 2024 00:46:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1510931#M85126</guid>
      <dc:creator>MK13</dc:creator>
      <dc:date>2024-07-27T00:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filter hard coded feature layer in React</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515598#M85214</link>
      <description>&lt;P&gt;This sample shows what you want to do:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/featurefilter-attributes/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/featurefilter-attributes/&lt;/A&gt;&amp;nbsp; Please look through our samples.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a sample codepen showing how to filter features based on attributes values from a button click:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/RwzgMBG?editors=100" target="_blank"&gt;https://codepen.io/U_B_U/pen/RwzgMBG?editors=100&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 16:25:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515598#M85214</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2024-08-06T16:25:34Z</dc:date>
    </item>
    <item>
      <title>Re: Filter hard coded feature layer in React</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515733#M85217</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/53756"&gt;@UndralBatsukh&lt;/a&gt;&amp;nbsp;please see my code below. I am unsure of how to create a view from the feature layer in experience builder/React. The filter method does not exist on the feature layer so the code below wouldn't work.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { React, type SqlQueryParams, type AllWidgetProps, DataSourceManager, type FeatureLayerDataSource } from 'jimu-core'
import { JimuMapViewComponent, type JimuMapView } from 'jimu-arcgis'
import FeatureLayer from 'esri/layers/FeatureLayer'

const { useState } = React //{} allow destructuring of this constant

const Widget = (props: AllWidgetProps&amp;lt;any&amp;gt;) =&amp;gt; {
  const omLyr = new FeatureLayer({
    url: 'https://services5.arcgis.com/M4Fx5dTKFkYlecLTsdsdsd/arcgis/rest/services/OpenMarketSm/FeatureServer'
  })
  const [jmv, setJmv] = useState&amp;lt;JimuMapView&amp;gt;()
  const activeViewChangeHandler = (jimumapview: JimuMapView) =&amp;gt; {
    if (jimumapview) {
      setJmv(jimumapview)
    }
  }
  const addLayerHandler = (evt) =&amp;gt; {
    evt.preventDefault()
    jmv.view.map.add(omLyr)
  }

  const filterLayerHandler = (evt) =&amp;gt; {
    evt.preventDefault()
    omLyr.filter = {
      where: "ServiceAreaType ='Comm. Recycling'"
    }
  }
  return (
      &amp;lt;div&amp;gt;
      &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={activeViewChangeHandler}/&amp;gt;)}
      &amp;lt;/div&amp;gt;
      &amp;lt;form onSubmit={addLayerHandler}&amp;gt;
        &amp;lt;button className='btn btn-primary'&amp;gt;
          Add Layer
        &amp;lt;/button&amp;gt;
      &amp;lt;/form&amp;gt;
      &amp;lt;form onSubmit={filterLayerHandler}&amp;gt;
        &amp;lt;button className='btn btn-primary'&amp;gt;
          Filter Layer
        &amp;lt;/button&amp;gt;
      &amp;lt;/form&amp;gt;
      &amp;lt;/div&amp;gt;
  )
}

export default Widget
//activeViewChangeHandler is called once when the map is ready
// {/* ?. checks if object is null  */}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 06 Aug 2024 20:02:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515733#M85217</guid>
      <dc:creator>MK13</dc:creator>
      <dc:date>2024-08-06T20:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Filter hard coded feature layer in React</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515823#M85219</link>
      <description>&lt;P&gt;It is already in the sample. You have to wait for &lt;A href="https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515733#M85217" target="_self"&gt;MapView.whenLayerView&lt;/A&gt; to resolve after you add the layer in your addLayerHandler function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 21:21:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515823#M85219</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2024-08-06T21:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Filter hard coded feature layer in React</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515844#M85222</link>
      <description>&lt;P&gt;That worked. Thanks. I had to retrieve the view from the jimumapview and then set the whenLayerView.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 22:02:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-hard-coded-feature-layer-in-react/m-p/1515844#M85222</guid>
      <dc:creator>MK13</dc:creator>
      <dc:date>2024-08-06T22:02:07Z</dc:date>
    </item>
  </channel>
</rss>

