Is it possible to change color of each icon in Feature Layer?

01-26-2021 12:14 AM
New Contributor

I am using ArcGIS Javascript 4.17

I have a feature layer like this

var testlayer = new FeatureLayer({
url: "{Some url here}",
outFields: ["*"], // Return all fields so it can be queried client-side
title: "my test layer"

This is a sample output:



Is it possible to change the color of each section (the icons inside red circle) to a different color on the fly with just one layer?

So for example this is my desired output color per section (one section is colored blue, one section is colored black, one section is colored green). Currently what I can think of is clone the feature layer then query then pass the data and create multiple feature layers per section with my desired color. But is there any other way to do this within just a single layer?




0 Kudos
3 Replies
by MVP Regular Contributor
MVP Regular Contributor

If the data has unique field values for the areas you want to color differently, you can use a unique values renderer.

MVP Regular Contributor

A link for your convenience :grinning_face:

UniqueValueRenderer | ArcGIS API for JavaScript 4.18

0 Kudos
Esri Regular Contributor

Hi, you could use Arcade to do this if you're sketching geometries. Here's a codepen showing how to encode the sketched geometries into an Arcade expression. You then use a UniqueValueRenderer to style the intersecting features how you want.