Select to view content in your preferred language

Symbolize colors using hex or rgb values from a field in ArcGIS Online

1673
8
10-11-2023 11:40 AM
Labels (1)
EricaNova
Frequent Contributor

I'd like to define colors for my feature layer categories from a field to ensure that the colors are always consistent, even though I may wipe and re-load data regularly from this feature layer. So, for example, "Animal01" would always be #FFFFFF and that hex value would be stored in my attribute table.

It looks like this is possible in Pro: https://support.esri.com/en-us/knowledge-base/how-to-apply-hex-or-rgb-color-codes-from-an-attribute-... - is this possible in AGOL? I'm going to be using a script to truncate and append to this feature layer regularly, so I need a solution that is going to work in AGOL without the go-between of Pro.

Tags (4)
0 Kudos
8 Replies
TristenDenton4
Regular Contributor

I'm not sure of a way to set hex values for a specific feature layer in AGOL, but if you're using this layer as a part of a webmap that is consistently updated, then I'm pretty sure you can save the symbology in the webmap for the layer and it will maintain that symbology for said webmap. That is, if you're overwriting the layer when you make updates. If you are removing the layer then adding a new one, I doubt this would work. Following though in case anyone has suggestions for the hosted layer/shapefile itself.

0 Kudos
RussRoberts
Esri Notable Contributor

Currently this is not possible in Map Viewer OOTB. We do not expose the attribute connection to define a primitive override like this. This is something we are looking into doing but currently not a near term project. We do however support reading in web maps that have been authored with a primitive override either manually constructed or written out from Pro. 

Here is a sample web map using an arcade expression in the primitive overrides to define the color on an RGB field. 

https://jsapi.maps.arcgis.com/apps/mapviewer/index.html?webmap=bcda0069313e43e8a63800c250b8bd84

0 Kudos
Elfendahl
Emerging Contributor

Hi Russ,

Could you elaborate a bit on how and where to set the primitive override to accomplish this? I have managed to set a primitive override to set the feature color from a table field for a layer in ArcGIS Pro. But whenever I export that feature layer to ArcGIS Online the color format from the table field is not in effect anymore.

RussRoberts
Esri Notable Contributor

Does the value used exist on the same layer or in another table/feature class. If that's the case it wont work.  

 

If thats not the case can you share the map and layer and I can take a look if I can spot an issue?

 

0 Kudos
EricaNova
Frequent Contributor

@RussRoberts yes - would appreciate a resource / link on how to use primitive overrides, I'm not familiar with that term.

 

0 Kudos
RussRoberts
Esri Notable Contributor

Only really written up here

https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/attribute-driven-symbology.ht...

and here

https://developers.arcgis.com/javascript/latest/api-reference/esri-symbols-CIMSymbol.html#PrimitiveO...

 

We are looking at exposing this in symbol styler in Map Viewer as well but its not on the immediate roadmap.

To
by
Occasional Contributor

@RussRoberts I wanted to ask if the status of this potential enhancement is unchanged (not on immediate roadmap)?

The main limitation with setting it in the webmap .json for my use case (symbolizing rooms based on departments, use codes, etc. in an ExB app) is that the Legend widget doesn't provide any meaningful information to the user.

 

Thank you!

0 Kudos
RussRoberts
Esri Notable Contributor

Not the the immediate road map to expose this functionality in symbol styler just yet in Map Viewer and same with the legend which would be seen across 4.x apps like Map Viewer or Experience Builder and Desktop apps like Pro