HOW TO

Display XY values in ArcGIS Online Map Viewer pop-ups using Arcade

Last Published: June 20, 2023

Summary

In ArcGIS Online, spatial and location information can be added to the pop-ups of point features, and this task can be automated using an Arcade expression. The workflow provided describes how to calculate the XY values of point features using an Arcade expression in ArcGIS Online Map Viewer.

Procedure

 

  1. Log in to ArcGIS Online and click Content > My Content.
  2. Browse to the hosted feature layer, click More Options The Options icon. and select Open in Map Viewer.
  3. On the Contents (dark) toolbar to the left of the page, click Layers The Layers icon..
  4. In the Layers pane, click the layer.
  5. On the Settings (light) toolbar to the right of the page, click Pop-ups The Pop-ups icon..
  6. In the Pop-ups pane, under Options, click Attribute expressions.
The Attribute expressions option under Options in the Pop-ups pane.
  1. In the Attribute expressions pane, click Add expression.
  2. In the Arcade expression editor window, click Edit to change the name of the field.
  3. In the Expression box, use either one of the following conversion expressions below and click Test.
  • For XY values in meter:
  1. Identify the x-value using either one of the following expressions.
return Round(Geometry($feature).X, <number of decimal place values>)
Text(Geometry($feature).x); 

The image below shows the Round(Geometry($feature).X, 2) expression used as an example.

The X-value expression configured in the Expression box.
  1. When the Results tab displays the coordinates, click OK.
  2. Follow Steps 7 through 9 and identify the y-value using either one of the following expressions. When the Results tab displays the coordinates, click OK.
return Round(Geometry($feature).Y, <number of decimal place values>)
Text(Geometry($feature).y); 

The image below shows the Round(Geometry($feature).Y, 2 expression used as an example.

The Y-value expression configured in the Expression box.
  • For XY values in decimal degrees:
  1. Identify the x-value.
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (Geometry($feature).x / originShift) * 180.0;
return [lon];
The X-value expression for decimal degrees configured in the Expression box.
  1. When the Results tab displays the coordinates, click OK.
  2. Follow Steps 7 through 9 and identify the y-value. When the Results tab displays the coordinates, click OK.
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lat = (Geometry($feature).y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return [lat];
The Y-value expression for decimal degrees configured in the Expression box.
  1. Click the Previous The Previous icon. button.
  2. In the Pop-ups pane, click Fields list and click Select fields.
The Fields list layer expanded and the Select fields option underneath.
  1. In the Selects fields pane, under Expressions, check the relevant expression fields and click Done.
The Expression layers in the Select fields pane.

The image below shows the XY values for all the conversion options displayed in the pop-up in ArcGIS Online Map Viewer.

A pop-up of a point feature with XY coordinates.

Article ID: 000028156

Software:
  • ArcGIS Online

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options