<?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 out graphics on GraphicsLayer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-out-graphics-on-graphicslayer/m-p/1232806#M79364</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You should use client-side FeatureLayer instead of GraphicsLayer if you want to filter features based on attributes. We have couple of samples that showcase how to create client-side feature layer from graphics&lt;/P&gt;&lt;P&gt;&lt;A href="https://next.sites.afd.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/" target="_blank"&gt;https://next.sites.afd.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://next.sites.afd.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection-edits/" target="_blank"&gt;https://next.sites.afd.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection-edits/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;FeatureLayer.source SDK help talks about how to create client-side layers:&amp;nbsp;&lt;A href="https://next.sites.afd.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source" target="_blank"&gt;https://next.sites.afd.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source&lt;/A&gt;&lt;/P&gt;&lt;P&gt;With all this said, you still must use GraphicsLayer then you could query all graphics in your GraphicsLayerView and set the visibility of graphics to false based on your needs. You can do something like this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.whenLayerView(graphicsLayer).then(function(layerView){
  layerView.queryGraphics().then(function(results){
    results.forEach((item)=&amp;gt;{
      console.log(graphic?.attributes)
      if (graphic?.attributes?.Name){ // set your requirement here
        graphic.visible = false;
      }
    });
  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 17:16:03 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2022-11-17T17:16:03Z</dc:date>
    <item>
      <title>filter out graphics on GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-out-graphics-on-graphicslayer/m-p/1232107#M79340</link>
      <description>&lt;P&gt;Is there a similar property or workaround like definitionExspression of a featureLayer but in graphicsLayer?&lt;/P&gt;&lt;P&gt;my goal is to filter out graphics with certain attributes from a graphicsLayer but not remove them.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 07:13:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-out-graphics-on-graphicslayer/m-p/1232107#M79340</guid>
      <dc:creator>Guy_srb</dc:creator>
      <dc:date>2022-11-16T07:13:31Z</dc:date>
    </item>
    <item>
      <title>Re: filter out graphics on GraphicsLayer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-out-graphics-on-graphicslayer/m-p/1232806#M79364</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You should use client-side FeatureLayer instead of GraphicsLayer if you want to filter features based on attributes. We have couple of samples that showcase how to create client-side feature layer from graphics&lt;/P&gt;&lt;P&gt;&lt;A href="https://next.sites.afd.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/" target="_blank"&gt;https://next.sites.afd.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://next.sites.afd.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection-edits/" target="_blank"&gt;https://next.sites.afd.arcgis.com/javascript/latest/sample-code/layers-featurelayer-collection-edits/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;FeatureLayer.source SDK help talks about how to create client-side layers:&amp;nbsp;&lt;A href="https://next.sites.afd.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source" target="_blank"&gt;https://next.sites.afd.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#source&lt;/A&gt;&lt;/P&gt;&lt;P&gt;With all this said, you still must use GraphicsLayer then you could query all graphics in your GraphicsLayerView and set the visibility of graphics to false based on your needs. You can do something like this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.whenLayerView(graphicsLayer).then(function(layerView){
  layerView.queryGraphics().then(function(results){
    results.forEach((item)=&amp;gt;{
      console.log(graphic?.attributes)
      if (graphic?.attributes?.Name){ // set your requirement here
        graphic.visible = false;
      }
    });
  });
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 17:16:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-out-graphics-on-graphicslayer/m-p/1232806#M79364</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2022-11-17T17:16:03Z</dc:date>
    </item>
  </channel>
</rss>

