Arcade is a new expression language that ESRI has created for use within the ArcGIS platform. It’s a portable, lightweight, and secure expression language written specifically for the ArcGIS platform. Like other expression languages, it can perform mathematical calculations, manipulate text, and evaluate logical statements. It also supports multi-statement expressions, variables, and flow control statements. Arcade was designed specifically for creating custom visualizations and labeling expressions. You can also use Arcade to customize labeling within ArcGIS Pro or ArcGIS online web maps. We’ll post more information related to how flexible Arcade is later but for now, if you need more info, look here.
I discovered this Arcade function within ESRI’s online forum back in May of 2019 and it’s helpful for converting the X, Y coordinates from the Web Mercator Projections that many of today’s world wide mapping services use (ie ArcGIS Online basemaps, Google Maps, Bing, Mapquest, etc).
Most of us are comfortable with geographic coordinates or commonly referred to as the Latitude and Longitude coordinate systems. They are also often displayed in a decimal degrees format such as: 35.2345566, -94.234456 It’s for this very reason that I needed an Arcade expression within my ArcMap web map. I simply wanted to display a pop-up or a map label with Geographic Coordinates because other map users are already familiar with it.
Open ArcGIS Online to get started.
- Open a ArcGIS Online map with a point feature service you own or can edit.
- Download the Arcade_ArcGIS_webMercator2LatLongLabel.txt file and then open it within Notepad or Notepad++ (for formatting purposes).
- Within your AGOL Map Viewer, left-click the More Options (circled below in blue) to open the map layer context menu; then select Configure Pop-Up.
- After selecting Configure Pop-up from the context menu, scroll down within the Configure Pop-up side panel until you see the ADD attribute expression dialog. Left-click the ADD button (blue circled).
- Once the Arcade Expression dialog opens, you’ll want to Edit the name of this script (LatLongLabel) in the upper-left corner
- Next, you will copy/paste the entire contents of the Arcade expression (.txt file) provided within this tutorial.
- It should already be open within Notepad or Notepad++, so hopefully the copy/paste will be easy.
- Paste the Arcade Expression into the Code Block section (left side/shaded blue in the screen shot below) and click the blue TEST button to confirm that there are no errors. A cleanly formatted lat/long coordinate pair is what you want to see.
- After Testing your Arcade expression, and if it’s OK, then click OK in the lower right corner to close the Arcade dialog.
- You should see your NEW custom arcade expression within the Attribute Expressions list of your Configure Pop-up dialog.
- Now, You will put this new LatLongLabel expression to use within your map pop-up. And, as you can see below, it’s formatted as Latitude, Longitude within the Pop-Up of this Trash Tag Web Map.
And there you have it, that’s how the Arcade scripting language can help you customize maps with labels and pop-ups that contain geographic coordinates.
Those coordinate pairs can be used to pass a URL string to other web services too, such as Survey123 for ArcGIS or even outside of the ArcGIS platform to Google Map Driving Directions services. If needed…
Take care; let me know if you have questions. I tried to keep this short as possible, so let me know if I can help.