HOW TO
In ArcGIS Online and Portal for ArcGIS Map Viewer, Arcade expressions with multiple statements can be used to split and reposition text strings of labels. The repositioned text strings can be used for data management. This article provides an example and instructions using Arcade expressions to split and rearrange text strings of labels for Map Viewer.
The image below shows a map in Map Viewer with labels.
var <variableName1> = Split($feature.<featureName>, ' ')
var <variableName2> = Count(<variableName1>)
if (<variableName2> == 0) { return '' }
if (<variableName2> == 1) { return $feature.<featureName> }
if (<variableName2> == 2) { return <variableName1>[1] + ' ' + <variableName1>[0] }
if (<variableName2> == 3) { return <variableName1>[1] + ' ' + <variableName1>[2] + ' ' + <variableName1>[0] }
The code block below shows the full working expression.
var arrName = Split($feature.Forest_Name, ' ') var lenName = Count(arrName) if (lenName == 0) { return '' } if (lenName == 1) { return $feature.Forest_Name } if (lenName == 2) { return arrName[1] + ' ' + arrName[0] } if (lenName == 3) { return arrName[1] + ' ' + arrName[2] + ' ' + arrName[0] }
The image below shows the newly configured labels after using the Arcade expression.
Article ID: 000029552
Get help from ArcGIS experts
Download the Esri Support App