HOW TO

Display the sum of intersecting features in Portal for ArcGIS Map Viewer pop-ups

Last Published: August 29, 2022

Summary

In Portal for ArcGIS Map Viewer Classic, Arcade expressions can be used to format the text displayed in a pop-up according to the specifications applied. This article provides an example and instructions using the Arcade expressions to display the sum of intersecting features for pop-ups in Portal for ArcGIS Map Viewer Classic.

Procedure

The workflow provided utilizes the Arcade functions listed in the table below to display the sum of point features within the polygon features in Portal for ArcGIS Map Viewer pop-ups.

Arcade FunctionAttribute Result
Count(features)Returns the number of features in a layer.
Intersects(features, inputGeometry)Returns features from a FeatureSet that intersects another geometry.
FeatureSetByName(featureSetCollection, title)Creates a FeatureSet from a Feature Layer based on its name within a map or feature service.
Round(value, numberOfDecimalPlaces)Returns the input value, rounded to the given number of decimal places.
AreaGeodetic(features, unitOfMeasurement)Returns the geodetic area of the feature in the given units.
Filter(features, sqlExpression)Filters features using an SQL92 expression.
Text(value, 'format')Converts the argument into a string and optionally formats it.
  1. In Map Viewer Classic, click Details, and click Content.
  2. Click More Options The More Option icon next to the layer next to the polygon layer, and click Configure Pop-up.
Selecting the Configure Pop-up option in the Contents pane
  1. Scroll down to the Attribute Expressions section in the Configure Pop-up pane and click ADD.
The ADD icon under the Attribute Expressions section in the Configure Pop-up pane
  1. In the Expression window, specify a name for the new expression as required.
  2. In the Expression dialog box, insert the following Arcade expression:
  1. Get all the trees and count them.
var <variableName> = Count(Intersects(FeatureSetByName($map, "<layerName>"), $feature))
  1. Calculate the tree density.
var <variableName1> = Round(TreesCount / AreaGeodetic($feature, '<unitOfMeasurement>'), <numberOfDecimalPlaces>)
  1. Get all the maple trees and count them.
var <variableName2> = Count(Intersects(Filter(FeatureSetByName($map, "<layerName>"), "<fieldName> LIKE '%<fieldValue>%'"), $feature))
  1. Construct the pop-up string.
var <variableName3> = "<text> " + $feature["fieldName1"] + " <text1> " + Text(<variableName>, '<format>') + " <text2> " + Text(<variableName1>, '<format>') + " <text3> " + Text(<variableName2>, '<format>') + " <text4>"

return <variableName3>

The following code block demonstrates the full working Arcade expressions.

var treesCount = Count(Intersects(FeatureSetByName($map, "Street Tree Data WGS84"), $feature))

var treeDensity = Round(TreesCount / AreaGeodetic($feature, 'square-kilometers'), 0)

var mapleTreesCount = Count(Intersects(Filter(FeatureSetByName($map, "Street Tree Data WGS84"), "COMMON_NAM LIKE '%MAPLE%'"), $feature))

var popupDisplay = "The neighbourhood of " + $feature["AREA_NAME"] + " has a total of " + Text(treesCount, '#,###') + " street trees making for " + Text(treeDensity, '#,###') + " trees per SQ KM. Of those trees, " + Text(mapleTreesCount, '#,###') + " of them are part of the Maple tree family."

return popupDisplay
  1. Click Test to view a preview of the expression result. If the required result is achieved, click OK.
The Arcade expression in the Arcade expression dialog box
  1. Under the Pop-up Contents section in the Configure Pop-up pane, click Configure Attributes.
The pop-up contents changed by clicking the Configure Attributes option in the Configure pane
  1. In the Configure Attributes window, check the fields required to be displayed in the pop-up and click OK. In this example, the Maple Tree Information field is checked, while all other fields are unchecked.
Selecting the Arcade expression field and removing all the other fields in the Configure Attributes window
  1. Click OK at the bottom of the Configure Pop-up pane.

The image below shows the configured pop-up with the information on the total number of trees, and the number of Maple trees for each polygon feature displayed.

The end result of the custom attribute display pop-up window
 

Article ID: 000028155

Software:
  • ArcGIS Online
  • Portal for ArcGIS

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