Select to view content in your preferred language

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

1562
3
01-26-2021 12:14 AM
CastielMye
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:

CastielMye_0-1611648561172.png

 

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?

CastielMye_1-1611648731393.png

 

 

0 Kudos
3 Replies
by Anonymous User
Not applicable

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

BlakeTerhune
MVP Regular Contributor

A link for your convenience 😀

UniqueValueRenderer | ArcGIS API for JavaScript 4.18

0 Kudos
KristianEkenes
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.  https://codepen.io/kekenes/pen/GRjVvJL

KristianEkenes_0-1611688125478.png