Mapping

May 2018

Create Custom Labels with ArcGIS Arcade Expressions

article image

How can you add informative, custom labels to your maps? With ArcGIS Arcade, a scripting language in ArcGIS Online and ArcGIS Pro, you can combine fields, perform calculations, and add text to create more descriptive labels without editing the source data. When your data isn’t perfect or the data you need for your labels is spread across multiple fields, Arcade expressions let you turn data back into useful information.

For example, this map visualizes the seven wonders of the modern world. There are two fields in the map’s layer: Title and Date of Construction. You will want to combine the data in these fields onto one label.

Geospatial Techs Turn in the Sun
Geospatial Techs Turn in the Sun

To create custom labels, follow these five short steps:

Step 1—Open this sample web map. Click Modify Map (found at the top right of the screen) and then click the Content tab (found on the left side of the screen). This opens the Contents view, which displays all the layers in your map.

Step 2—Select the More Options symbol (the three dots under the layer name) and click Manage Labels in the drop-down menu. This opens the label editor, where you can customize your layer’s labels.

Geospatial Techs Turn in the Sun

Step 3Select the Edit Expression pencil symbol, to the right of the Text drop-down menu.

Geospatial Techs Turn in the Sun

The sample map currently displays the name of each of the seven wonders of the modern world. This is shown with the title field ($feature.Title).

Geospatial Techs Turn in the Sun

Step 4Add the year of construction to the label to make it more informative.

To do this, type a plus sign, a colon in quotation marks, and another plus sign (+ “: ” +) to the right of $feature.Title. We use a plus sign because we’re adding words together. Make sure to add a space after the colon so that the labels are nicely spaced.

Now click the Date of Construction field, in blue ($feature.Date_of_Construction), which adds it to the editor.

Geospatial Techs Turn in the Sun

Click the blue Test button to see how your label will look. The Arcade expression combines multiple fields and returns a label like “Taj Mahal: 1643 CE”.

When you’re ready, click OK. Notice how the year now appears in your map.

Geospatial Techs Turn in the Sun

Step 5Edit the label size, color, halo, and position to best match your map. The Visible Range slider determines when your labels appear. For example, click on the left side of the light gray slider bar and move the slider to the right of the black triangle (the map’s current zoom level). Notice how the labels disappear from the map. We use this feature when the labels no longer look good at certain scales (e.g., when zoomed out). Return the slider to the far left, the World scale.

Geospatial Techs Turn in the Sun

Click OK to return to the Content view to admire your custom labels!

Geospatial Techs Turn in the Sun

Arcade expressions aren’t just for labels. You can also implement expressions for symbology and pop-ups. Explore more use cases with the Arcade expression guide and view web map examples in the Arcade Expressions and You gallery!

Share this article