HOW TO

Runden numerischer Werte mit mehreren Bedingungen unter Verwendung von Arcade-Ausdrücken in ArcGIS Online

Last Published: February 9, 2024

Zusammenfassung

Pop-ups in ArcGIS Online can be configured using custom expressions written in the Arcade expression language. Expressions can be used to generate new data with reference to an existing field in a layer that has different values.

This article provides the steps to round the values of a field to the nearest thousand for numbers above 100,000, and the nearest million for numbers above 1,000,000 in ArcGIS Online Map Viewer. In this example, the value of the TOTPOP_CY field is referenced to round the numeric value for each symbol.

Vorgehensweise

  1. Open the map in Map Viewer. Click Layers on the Contents (dark) toolbar, and select the <layer name> with the pop-up for editing.
The Map Viewer Contents (dark) toolbar with the Layers tab
  1. Click Configure pop-ups on the Settings (light) toolbar > Manage expressions.
The Map Viewer Pop-ups pane used to navigate to the Map Viewer Pop-up expressions pane
  1. Click + Add expression to open the Arcade expression editor window.
The Map Viewer Pop-up expressions pane with the Add expression icon
  1. Specify the following Arcade expression in the Expression window:
var <variableName> = $feature.<fieldName>

if (<variableName> >= 1000000) {
    return (Text(Round(<variableName> / 1000000 , 2) * 1000000) / 1000000 + " M")
} else if (<variableName> >= 100000 && <variableName> < 1000000) {
    return (Text(Round(<variableName> / 100000 , 2) * 100000) / 1000 + " K")
}
else {
    return Text(Round(<variableName> , 2))
}
  1. Rename the New expression and click OK.
Specifying the Arcade expression in the Map Viewer Expression window
  1. Click the Previous button above the newly created Arcade expression in the Pop-up expressions pane.
The Map Viewer Pop-up expressions pane with the newly added expression
  1. Click Fields list to expand the list of fields displayed in the pop-ups, and click Select fields.
The Map Viewer Select fields pane to select fields to be displayed in the pop-up
  1. Check the expression field, and click Done.
The Map Viewer Select fields pane to select fields to be displayed in the pop-up

The pop-up display without the Arcade expression.

An example of the Map Viewer pop-up without the Arcade expression

The pop-up display after applying the Arcade expression.

An example of the Map Viewer pop-up with the Arcade expression enabled

Artikel-ID: 000027315

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