Using ArcGIS Arcade to your story's advantage

2181
5
09-27-2023 12:09 PM
AbbyE_Esri
Esri Contributor
6 5 2,181

One of the many reasons people love ArcGIS StoryMaps is its simplicity- but what are your options when you want to add more complexity to your story than what seems possible in the app?

That’s when you may want to consider using ArcGIS Arcade to provide enhanced customization to your story’s mapping components, such a map pop-ups.

 

What is ArcGIS Arcade?

If you’ve never heard of ArcGIS Arcade, it’s an expression language that can customize content coming from ArcGIS apps. For example, it can perform calculations on data from feature layers, which can then be used as your text for pop-ups, or even to stylize text. It is also a desirable customization tool due to its ability to utilize geometry data (think points, lines, and polygons) in its calculations and results, like applying a 10 meter buffer around existing data points.

One advantage to using ArcGIS Arcade is its dynamic nature: you can apply a calculation to all data within your story, and if that data changes frequently, so will your expression results (as noted in Your Arcade Questions Answered). To learn more about the basics of ArcGIS Arcade, take a look at the links at the bottom of the story.

 

Arcade expressions

When building an expression in Arcade, you can use a combination of profile variables and functions. These items are organized in the tabs of the Arcade expression editor.

Tabs:

  • Profile variables: Within this tab, you can select inputs for your expression based on the data within your map. For example, the $feature profile variable will hold a selection of the feature layers within your web map that you can select to add to your Arcade expression. You can also build these expressions based off of views you’ve created with the $view variable.

  • Functions: Here you’ll find all the functions you can apply to your data, from reformatting dates, to applying a buffer. Check out this page for a glossary of the available functions.

  • Suggestions

    • Templates!

      • If you are trying to build an expression and don’t know where to start, try out one of the suggested templates. This will give you an expression with generic variables that you can manually alter to utilize your own variables. There are even templates for creating charts:

         

Screenshot 2023-08-30 at 9.04.38 AM.png

A word on arcade functions

It’s up to you to decide how you want to use the functions in the expression editor, whether it be to alter the visual style of your layer, or to customize the information in your pop-up.

  • Some of the main tools you can use in the expression editor include:

    • Date functions

      • Perform actions like calculating a week ahead from the original date (‎DateAdd(dateValue, addValue, units?)), or converting a date/time to the time zone of the reader (‎ToLocal(inputDate)).

    • Math functions

      • Any calculation you can imagine, you can probably accomplish with Arcade. Think getting the mean of numbers (‎Average(numbers)), the sum (‎Sum(numbers)), or even generating a random number each time the arcade function is called (Random()).

    • Text functions

      • Here you can apply any format to the data (‎Text(value, format?)), remove undesirable spacing from text coming from your data (‎Trim(inputText)), or even call the specified number of characters from the beginning of a text value (‎Left(value, charCount)).

 

Arcade and pop-ups

You can use Arcade to format your pop-ups by calculating statistics from your layer, without having to make entirely new fields that are precisely formatted with this pre-calculated data.

 

Arcade and layer styles

Using ArcGIS Arcade on your layer can help transform the visualization of your data. Let’s say you want to apply a buffer to your Fault line data to inform your reader of when they may be buying a home near an earthquake prone area. You can apply that buffer with Arcade!

 

Calculating fields for map tours

Another place to utilize ArcGIS Arcade is within the fields of a feature layer that you’re planning to use for a data-driven map tour. You can calculate values of a new feature layer field based on data within the existing fields. This results in highly customizable data-driven map tours.

  • To calculate one of your feature layer fields, go to the item details page of your feature layer. Click the Data tab, then the Options bar on the table to click Add Field. Lastly, click on the new field title and click Calculate.

Use your customized field as your descriptions for your map tour points. If you’re working with a lot of data, this can save significant time by concatenating the important details of your fields. It can also be helpful for performing data analysis on your fields, in bulk, like calculating an average distance from a point, reformatting a date, or returning a certain field over another depending on the logic supplied!

Here’s a simple example of concatenation performed on a feature layer of Los Angeles Historical Sites. Let’s say you wanted to combine the information like hours of operation, and what number to call for additional information. The result was the calculated Map Tour Descriptions field:

Screenshot 2023-08-29 at 2.24.27 PM.png

A note here that when calculating a field from the Data tab, this calculation will be run in bulk for all features. It will NOT update when changing data from referenced fields, and it will not save the previously utilized calculation. This makes it a great tool for information that isn’t likely to change over time, like distances between fixed points.

You can also go in after running the calculation and manually alter individual results to your liking.

Now, I’ve created a map tour from the feature service, and designated the Map Tour Descriptions field as the Place description:

image-20230829-184308.png

 

How can you use ArcGIS Arcade in your story?

Sometimes, you want to add some more depth to your map’s pop-ups and visualization. While you can’t perform this operation right from the ArcGIS StoryMaps builder, you can complete this through formatting your pop-ups in the Map viewer with Arcade.

Let’s take a look at the Arcade expression editor together:

 

Screen Recording 2023-07-03 at 3.07.40 PM.gif

There are three main places to use Arcade within your web map: Your pop-ups and your layer style.

  • To get to the Arcade expression editor for your pop-up, click Pop-ups on the Settings toolbar, and the Add content button to find Arcade.

  • To open the Arcade expression editor for your layer styles, click Layers on the Contents toolbar. In the Layers pane select your desired layer, then click Styles on the Settings toolbar. Click Expression on the Styles pane.

 

Where should you start?

Take a look at your story and decide what it might benefit from; Does your story need richer pop-ups, or more relevant map visualization for the story’s focus? Maybe you’d like to provide highly customized descriptions in your map tour. All of these items can be added with a little help from ArcGIS Arcade.

 

Let's Learn

There are countless resources to help familiarize yourself with ArcGIS Arcade. Here are just a few tutorials and reference documents to get you started:

 

Resources:

Get started with ArcGIS Arcade

Arcade | Documentation | ArcGIS Developers

Access attributes from another layer with ArcGIS Arcade

GitHub - Esri/arcade-expressions: ArcGIS Arcade expression templates for all supported profiles in t...

 
5 Comments
Smith_Mike
Emerging Contributor

Abby,

@OwenGeo referred me to your blog. It was Great and even helped with some of the links you have at the bottom that led me to "Your Arcade Questions Answered" by Lisa Berry. But I still have one question. I have one line of text coming from an attribute that I have concatenated into another field for putting text into a header of my Story Map. I can't figure out how to make the one line italic. Mainly because I don't know how to make anything italic in Arcade. I could figure out how to take it out of the concatenation and reinsert it then continue with the concatenation, but I don't know the right tag or switch to turn the Italicism on and off. Below is the Concatenate command that let's me stack the text from attributes into one using Arcade. I need the $feature.Genus_botanical to be italicized. I've tried using html tags like <i> </i> or even the Arcade Text([$feature.Genus_botanical], italic) to try and do it, but neither worked. Can you help?

Concatenate([$feature.name,$feature.Genus_botanical, "Family "+$feature.Family,$feature.Origin_Region,"Height "+$feature.Height,"Width "+$feature.Width,"USDA Zone "+$feature.Plant_Zone],textformatting.newline)

Concatenate([$feature.name,$feature.Genus_botanical, "Family "+$feature.Family,$feature.Origin_Region,"Height "+$feature.Height,"Width "+$feature.Width,"USDA Zone "+$feature.Plant_Zone],textformatting.newline)

AbbyE_Esri
Esri Contributor

Hi @Smith_Mike ,

I hope you're well! I'm glad this post found you and helped a bit with building your expressions! If I am thinking this through correctly, The problem here is that the text formatting will be coming from HTML- there isn't a way to add this formatting with Arcade. I can think of how to work around this in the pop-ups, by adding formatting to items outside of the concatenation, then combining the italicized feature and the concatenated features in a text expression: 

Screenshot 2024-02-26 at 10.34.29 AM.png

Screenshot 2024-02-26 at 10.02.01 AM.png

The only way I could think this possible when running the calculation through the fields would be to add the italics on the field items that you are looking to italicize (in your case, the Genus botanical field) before running the concatenation in the field used for the calculation. The italics will come through in the calculation:

Screenshot 2024-02-26 at 10.32.41 AM.png

Let me know if this sounds feasible to you, and I'll let you know if I think of any other potential solutions.

--Abby

Smith_Mike
Emerging Contributor
Thank You So Much for your reply Abby. I had thought of something like that, but wasn’t sure how to do it. I still tried it in the string before the concatenate command yesterday morning and it didn’t work. However I used ArcPro to put the html tags in the actual values of the attribute field and it italicized the value. When calculating the new attribute for the Header the value in the attribute for the header is italicized also. Just not in the Story Map ☹
I don’t understand why either. Somehow I made a mistake this morning and calculated the description field with the header information. The correct value WAS italicized there. Once I changed the description back to what it should be and used the same process on the Header there is still no italicization.
In Story Map Tour that I am using, the Place title is what I am using with this concatenate tool and italicization. That is a different font and bolder. That could have something to do with it. Is there any way to change that?

Mike Smith
GIS Specialist
Information Technology
City of Lakeland<>
p. 863.834.6312
facebook.com/lakelandgov<>
@lakelandgov<>
[cid:image001.png@01DA694C.B307E140]


AbbyE_Esri
Esri Contributor

Hi @Smith_Mike ,

We looked into this a bit more, and at the moment, our titles within map tours strip any HTML formatting and only utilize bold when focusing on a specific map tour point, while our descriptions do still allow that HTML formatting (as your troubleshooting can attest to). Additionally, the HTML formatting that is honored between map tours built off of a feature service vs. the formatting honored in map tours built manually, is slightly different.

Because of this, we are working on updating the map tours so that titles and descriptions, no matter how they are built, will honor utilized HTML formatting tags, and allow for the following settings: Italics, strikethrough, subscript, and superscript. We hope to push through this change in the coming months, but I will let you know when that enhancement is live in the product by adding a comment on this thread.

Thank you for bringing this to our attention! 

--Abby

Smith_Mike
Emerging Contributor
Thank You So Much Abby! I had actually used the html tags extensively in one of me classic Story Maps to enhance the readability of it from a mobile device. It was naturally something I tried here, but didn't have the same affect. I'm glad it will be an enhancement and I appreciate your attention and effort in this situation. I'm glad to know I wasn't doing something wrong also. I even found a new way to stack text using the concatenate command. That might be something else to consider for the headings also. The numbering, bullet, centering, or left-right justification for headings.