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

629
1
05-13-2020 08:28 AM
AlinaT
by
New Contributor III

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 Reply
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