HOW TO

Erstellen von benutzerdefinierten Beschriftungen für bestimmte Features in ArcGIS Online-Webkarten unter Verwendung von Arcade-Ausdrücken

Last Published: December 12, 2023

Zusammenfassung

Arcade expressions can be used to write label expressions in ArcGIS Online web maps. It is possible to customize web map labels on a feature by feature basis using a simple conditional expression. This can be useful to differentiate features, for example, to give clarity to an urgent feature. The conditional syntax for Arcade expressions consists of 'if', 'else if', and 'else'. The condition is placed within parentheses, and the result is placed between curly brackets.

This article provides steps to create custom labels using Arcade expressions in ArcGIS Online Map Viewer Classic.

Vorgehensweise

  1. Open the web map in ArcGIS Online Map Viewer Classic.
  2. Click the More Optionsthe image of the More Options button button, and select Create Labels, or if labels are available, Manage Labels.
  3. In the Label Features side panel, select New Expression under the Text drop-down box to open the Arcade Expression window.
The image of the Text drop-down box
  1. Use the following sample code to customize labels for specific features. In the following example, the script is set to only label features with OBJECTID 1 and 2.
if ($feature.OBJECTID == 1) {
return 'One'
} 

else if ($feature.OBJECTID == 2) {
return 'Two'
}

The image below demonstrates the resulting label.

Image of the resulting label

Alternatively, the script in Step 4 can also be modified to create custom labels to differentiate certain features. In the following example, only the feature with OBJECTID 1 is labeled with a text, and the remaining feature is labeled using the numeric OBJECTID value.

if ($feature.OBJECTID == 1) {
    return 'One'
}

else {
    return $feature.OBJECTID
}

The image below demonstrates the resulting label.

Image of the resulting label

Artikel-ID:000017839

Benachrichtigungen erhalten und Lösungen für neue oder häufige Probleme finden

Unser neuer KI-Chatbot stellt zusammengefasste Antworten und Videolösungen für Sie bereit.

Esri Support App herunterladen

Zugehörige Informationen

Weitere Informationen zu diesem Thema erkunden

Unterstützung durch ArcGIS-Experten anfordern

An den technischen Support wenden

Esri Support App herunterladen

Zu Download-Optionen wechseln