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:
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
Solved! Go to Solution.
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-...
Unfortunately, the Map Viewer doesn't support label formatting tags in Arcade
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-...
Unfortunately, the Map Viewer doesn't support label formatting tags in Arcade
Thanks!