How do I change the text color of my label in AGOL using Arcade Expression?

1893
2
Jump to solution
05-13-2020 08:28 AM
JonahW
by
Regular Contributor

I have a web map where my assets are labeled with the FacilityID.  I want to have a different label (a custom text) for a specific asset. The code below works fine: 

var label = $feature.FACILITYID;

iif(label=='2793','STAY OUT OF DRIVEWAY',label);

However, if I want the text to display differently (bold or in red) I can't get the formatting to work. Here is one example I tried:


var label = $feature.FACILITYID;
var redlabel= "<CLR red='255'>" + 'STAY OUT OF DRIVEWAY'+ "</CLR>";
iif(label=='2793',redlabel,label);

This returns: 

<CLR red='255'>STAY OUT OF DRIVEWAY</CLR>

I've tried all sorts of combinations for single quotes and double quotes, nothing seems to work. Any suggestions? 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Alina Taus ,

The current web map in ArcGIS Online, does not allow you to use the formatting tags you can use in Desktop. You could copy the layer in you web map and filter it and then change the formatting of the text label for specific features.

The new beta map viewer does have more possibilities to define the labels. Although I have not seen support for formatting tag, you do not have to copy the layer to define different types of text fonts for your features. You can just add a label class and define an Arcade expression to filter the features you're interested in.

View solution in original post

0 Kudos
2 Replies
XanderBakker
Esri Esteemed Contributor

Hi Alina Taus ,

The current web map in ArcGIS Online, does not allow you to use the formatting tags you can use in Desktop. You could copy the layer in you web map and filter it and then change the formatting of the text label for specific features.

The new beta map viewer does have more possibilities to define the labels. Although I have not seen support for formatting tag, you do not have to copy the layer to define different types of text fonts for your features. You can just add a label class and define an Arcade expression to filter the features you're interested in.

0 Kudos
JaredPilbeam2
MVP Regular Contributor

Formatting tags in AGOL labels are still not doable as of today's Map Viewer. I shared a layer from Pro where the expression worked just fine, not so in AGOL. Great suggestion, however.

JaredPilbeam2_0-1722437699443.png

 

0 Kudos