Arcade symbology expression working in Pro, but not in AGOL?

371
3
Jump to solution
02-22-2024 06:56 AM
Labels (1)
LeslieO_Hare2
New Contributor II

Hi, 

I have a label expression written in Arcade that works in ArcGIS PRO (v. 3.0), but it is not working correctly in AGOL.  Basically, I want to label (and format) an address in one of the following ways depending on unit or building number existing in a separate field:

  1. Street Number (if no unit or bldg num)
  2. Street Number + Unit (if unit, no bldg num)
  3. Street Number + Bldg (if no unit, bldg num)
  4. Street Number + Bldg + Unit (if unit & bldg num)

The expression below works in ArcGIS Pro, but it is not working in AGOL.  I am pretty new to Arcade,  and any help appreciated!

var s = $feature.STNUM
var u = $feature.UNIT
var b = $feature.BUILDING;

If(!IsEmpty(u) && !IsEmpty(b)){
return "<BOL>" + s + "</BOL>" + textformatting.newline + "<BOL><CLR red = '150' green= '131'><FNT size= '7'>" + "B " + "</FNT></CLR></BOL>" + "<FNT size= '7'>" + b + "</FNT>" + textformatting.newline + "<BOL><CLR red = '255'><FNT size= '7'>" + " U " + "</FNT></CLR></BOL>" + "<FNT size= '7'>" + u + "</FNT>"
}
If(IsEmpty(u) && !IsEmpty(b)){
return "<BOL>" + s + "</BOL>" + textformatting.newline + "<BOL><CLR red = '150' green = '131'><FNT size= '7'>" + "B " + "</FNT></CLR></BOL>" + "<FNT size= '7'>" + b + "</FNT>"
}
If(!IsEmpty(u) && IsEmpty(b)){
return "<BOL>" + s + "</BOL>" + textformatting.newline + "<BOL><CLR red = '150' green = '131'><FNT size= '7'>" + " U " + "</FNT></CLR></BOL>" + "<FNT size= '7'>" + u + "</FNT>"
}
else {return "<BOL>" + s + "</BOL>" }

Thanks,

Leslie O'Hare

0 Kudos
2 Solutions

Accepted Solutions
GIS_Spellblade
Occasional Contributor

This blog walks through the process if you're using the not old Map Viewer:
https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/color-pop-ups/

You would likely want to restructure your arcade expression to return a WHEN statement against the unit and building not being null; and the default can be an empty string "". That would reproduce the same as it exists in ArcGIS Pro.
https://developers.arcgis.com/arcade/function-reference/logical_functions/#when

The other thing that I might do is to tidy up the HTML tags by wrapping them in a few variables since all of them are being reused in various ways. You can also use string literals to make it neater as well:
https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/manage-your-strings-quite-literally-...

View solution in original post

0 Kudos
KenBuja
MVP Esteemed Contributor

Unfortunately, the Map Viewer doesn't support label formatting tags in Arcade

View solution in original post

0 Kudos
3 Replies
GIS_Spellblade
Occasional Contributor

This blog walks through the process if you're using the not old Map Viewer:
https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/color-pop-ups/

You would likely want to restructure your arcade expression to return a WHEN statement against the unit and building not being null; and the default can be an empty string "". That would reproduce the same as it exists in ArcGIS Pro.
https://developers.arcgis.com/arcade/function-reference/logical_functions/#when

The other thing that I might do is to tidy up the HTML tags by wrapping them in a few variables since all of them are being reused in various ways. You can also use string literals to make it neater as well:
https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/manage-your-strings-quite-literally-...

0 Kudos
KenBuja
MVP Esteemed Contributor

Unfortunately, the Map Viewer doesn't support label formatting tags in Arcade

0 Kudos
LeslieO_Hare2
New Contributor II

Thanks!

0 Kudos