HOW TO

Display attributes of intersecting features in a pop-up via ArcGIS Arcade

Last Published: August 18, 2023

Summary

In ArcGIS Online and Portal for ArcGIS Map Viewer, pop-ups display attribute information of feature layers available in a web map. Displaying attributes of intersecting features from different layers in a pop-up ensures the clarity of the information portrayed on the map. This article provides the workflow to display the attributes of the intersecting features in a pop-up via ArcGIS Arcade in ArcGIS Online and Portal for ArcGIS Map Viewer.

The images below show the attributes of the feature from Layer1 and the attributes of an intersecting feature from Layer2 on the map. The workflow provided uses an Arcade expression to display the AREA_NAME field of the feature from Layer2 in the pop-up of the feature from Layer1.

Attributes of a feature from Layer1
Attributes of an intersecting feature from Layer2

Procedure

  1. In ArcGIS Online or Portal for ArcGIS Map Viewer, open the web map containing the features.
  2. On the Contents (dark) toolbar, click Layers to open the Layers pane and select the layer with the pop-up to be configured.
The Contents (dark) toolbar
  1. On the Settings (light) toolbar, click Pop-ups.
  2. In the Pop-ups pane, click Attribute expressions under Options.
The Settings (light) toolbar and the Pop-ups pane
  1. In the Attribute expressions pane, click + Add expression.
The Attribute expressions pane
  1. In the editor window, specify the name for the Arcade expression and click Save.
Edit and save the name for the Arcade expression in the Arcade expression editor window
  1. In the Expression window, specify the Arcade expression.
    1. To specify the layer and the field to be added, use the FeatureSetByName function. Insert the following expression:
var <VariableName1> = FeatureSetByName($map, "<LayerName>", ["<FieldName>"])
  1. To create buffers for the features in the configured layer and set the buffer size, insert the following expression. Get the intersecting features from the layers on the map.
var <VariableName2> = Intersects(<VariableName1>, Buffer($feature, <BufferSize>))
  1. To set the output string, insert the following expression:
var <VariableName3> = ''
  1. To populate the string with the intersected features from the added layer, insert the following expression:
for (var <VariableName4> in <VariableName2>){
    var <VariableName5> = DomainName(<VariableName4>, '<FieldName>')
    <VariableName3> += `${<VariableName5>}, `}
  1. To remove the last two characters from the output string, insert the following expression:
return Left(<VariableName3>, Count(<VariableName3>) - 2)
The code below shows the full working script.
var feat = FeatureSetByName($map, "Layer1", ["AREA_NAME"])
var intersectFeat = Intersects(feat, Buffer($feature, 1))
var out_str = ''

for (var x in intersectFeat){
    var feat_name = DomainName(x, 'AREA_NAME')
    out_str += `${feat_name}, `}

return Left(out_str, Count(out_str) - 2)
  1. Click OK.
  1. In the Attribute expressions pane, click Previous The Previous icon, found above the newly created Arcade expression.
  2. In the Pop-ups pane, click Fields list > Select fields.
  3. Under Expressions, select the newly created Arcade expression and click Done.

The pop-up of the feature from Layer1 below shows the Area Name field of the intersecting feature from Layer2 after applying the Arcade expression in Map Viewer.

The final output pop-up in Map Viewer

Article ID: 000028227

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

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options