Label features using Arcade expressions
This sample demonstrates how to label features in a FeatureLayer using an Arcade expression. Arcade is a simple, lightweight scripting language that can evaluate expressions at runtime. You can access feature attributes within Arcade using the
$feature profile variable. For example, to label cities with a
CITY_ field, you can do so in the following manner:
$feature.CITY_. Arcade provides a series of built-in functions that allow you to perform mathematical calculations and logical operations within your expression. The final line of the expression must evaluate to a string or a number.
For example, this sample uses the When() function to reclassify wind direction values to either
NW. The final line of the wind direction expression is returned as the label text. To read more details about Arcade and its syntax, see the Arcade guide page.
See the Labeling guide page for more information and known limitations.