<?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 Layer and Pass Value in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500948#M84973</link>
    <description>Oh my gosh, thank you, thank you, thank you. That worked.&lt;BR /&gt;&lt;BR /&gt;I realize I'm making things harder but let me explain what I'm attempting to do. I have a layer of colleges that includes two attributes for school colors. They are in hex values. I wanted to write a program that would use these values to automatically color the symbol and label using the school's colors. The only way I could vary the label color was to create a graphics layer.&lt;BR /&gt;&lt;BR /&gt;It may not be the most useful program, but it certainly helped me learn a lot.&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;BR /&gt;</description>
    <pubDate>Wed, 03 Jul 2024 13:20:27 GMT</pubDate>
    <dc:creator>mjbrgis</dc:creator>
    <dc:date>2024-07-03T13:20:27Z</dc:date>
    <item>
      <title>Filter Layer and Pass Value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500300#M84962</link>
      <description>&lt;P&gt;I have created a layer of Virginia Colleges and Universities. I have also added a filter for public or private schools. The full code is here:&amp;nbsp;&lt;A href="https://github.com/mjbrgis/geojson/blob/main/layers-AGOL-VA-colleges-sample.html" target="_blank"&gt;https://github.com/mjbrgis/geojson/blob/main/layers-AGOL-VA-colleges-sample.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The labels for the schools are separate graphics layers. I want to be able to add or remove graphics layers based on the chosen filter. However, I can't for the life of me figure out how to pass the chosen filter value to another function. The general idea is this:&lt;/P&gt;&lt;P&gt;- initial load shows all schools and all labels&lt;BR /&gt;- filtering for public schools shows public schools, removes all labels, shows public labels, removes private labels (if necessary)&lt;BR /&gt;- filtering for private schools shows private schools, removes all labels, removes public labels (if necessary), shows private labels&lt;/P&gt;&lt;P&gt;Any advice would be much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 13:46:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500300#M84962</guid>
      <dc:creator>mjbrgis</dc:creator>
      <dc:date>2024-07-02T13:46:28Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Layer and Pass Value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500317#M84963</link>
      <description>&lt;P&gt;You will want to use FeatureLayers, not GraphicLayers.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;If you can think of an idea for a map, there is probably a very similar coding sample. This one shows how to build a button that filters a FeatureLayer by its attributes.&lt;/P&gt;&lt;P&gt;&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;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 14:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500317#M84963</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2024-07-02T14:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Layer and Pass Value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500541#M84965</link>
      <description>&lt;P&gt;Thank you but I'm using graphics layers because I want the label colors to vary. If I use labels on a feature layer, they will all be colored the same.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 19:31:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500541#M84965</guid>
      <dc:creator>mjbrgis</dc:creator>
      <dc:date>2024-07-02T19:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Layer and Pass Value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500557#M84966</link>
      <description>&lt;P&gt;GraphicLayers are intended to be used as just graphics. It is possible to get what you want out of a GraphicLayer, but it will be a lot more work and perform worse than filtering a FeatureLayer.&lt;/P&gt;&lt;P&gt;If you need to use multiple label styles in a FeatureLayer, you can set up label classes, like this example.&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/labels-multiple-classes/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/labels-multiple-classes/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 19:52:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500557#M84966</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2024-07-02T19:52:30Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Layer and Pass Value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500663#M84967</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/677423"&gt;@JeffreyThompson2&lt;/a&gt;&amp;nbsp;makes good points here, and were I to create this my design would be along those lines.&amp;nbsp; You may very well end up doing a redesign, but as it stands you have a 99.9% solution for the problem you've described, and you also seem interested in knowing where you went wrong.&amp;nbsp; As such, It looks to me like the problem lies in the "filterByCollege" function, which you have as follows:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function filterByCollege(event) {
	let selectedCollegeType = event.target.getAttribute("TYPE");
	collegeLayerView.filter = {
		where: "TYPE = '" + selectedCollegeType + "'"
	};
	map.remove(graphicsLayer);
	//map.add(graphicsLayerPublic);
	map.add(graphicsLayerPrivate);
	console.log(selectedCollegeType);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By changing it to the following, it appears to behave like what you've described:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function filterByCollege(event) {
	let selectedCollegeType = event.target.getAttribute("TYPE");
	collegeLayerView.filter = {
		where: "TYPE = '" + selectedCollegeType + "'"
	};		  
	map.remove(graphicsLayer);
	if (selectedCollegeType == "Public") {
		map.add(graphicsLayerPublic);
		map.remove(graphicsLayerPrivate);
	} else {
		map.remove(graphicsLayerPublic);
		map.add(graphicsLayerPrivate);
	}
	console.log(selectedCollegeType);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, removed lines 7 and 8 from the original, and added lines 7-13.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2024 23:24:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500663#M84967</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2024-07-02T23:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: Filter Layer and Pass Value</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500948#M84973</link>
      <description>Oh my gosh, thank you, thank you, thank you. That worked.&lt;BR /&gt;&lt;BR /&gt;I realize I'm making things harder but let me explain what I'm attempting to do. I have a layer of colleges that includes two attributes for school colors. They are in hex values. I wanted to write a program that would use these values to automatically color the symbol and label using the school's colors. The only way I could vary the label color was to create a graphics layer.&lt;BR /&gt;&lt;BR /&gt;It may not be the most useful program, but it certainly helped me learn a lot.&lt;BR /&gt;&lt;BR /&gt;Thanks again.&lt;BR /&gt;</description>
      <pubDate>Wed, 03 Jul 2024 13:20:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/filter-layer-and-pass-value/m-p/1500948#M84973</guid>
      <dc:creator>mjbrgis</dc:creator>
      <dc:date>2024-07-03T13:20:27Z</dc:date>
    </item>
  </channel>
</rss>

