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
- Log in to ArcGIS Online and click Content > My Content.
- Browse to the hosted feature layer, click More Options and select Open in Map Viewer.
- On the Contents (dark) toolbar to the left of the page, click Layers .
- In the Layers pane, click the layer.
- On the Settings (light) toolbar to the right of the page, click Pop-ups .
- In the Pop-ups pane, under Options, click Attribute expressions.
- In the Attribute expressions pane, click Add expression.
- In the Arcade expression editor window, click Edit to change the name of the field.
- In the Expression box, use either one of the following conversion expressions below and click Test.
- 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.
- When the Results tab displays the coordinates, click OK.
- 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.
- For XY values in decimal degrees:
- Identify the x-value.
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (Geometry($feature).x / originShift) * 180.0;
return [lon];
- When the Results tab displays the coordinates, click OK.
- 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];
- Click the Previous button.
- In the Pop-ups pane, click Fields list and click Select fields.
- In the Selects fields pane, under Expressions, check the relevant expression fields and click Done.
The image below shows the XY values for all the conversion options displayed in the pop-up in ArcGIS Online Map Viewer.