操作方法

操作方法:在 ArcGIS Online 弹出窗口中显示相关表中多个属性字段值的总和

Last Published: April 25, 2020

摘要

ArcGIS Online 允许使用相关表来配置要素图层的弹出窗口,以便在弹出窗口中显示相关数据。 但是,要在弹出窗口中计算并显示多个属性字段值的总和,必须使用 Arcade 来完成某些属性表达式的配置。 本文提供了工作流,以使用要在弹出窗口中显示的 Arcade 来计算要素图层的相关表中多个属性字段值的总和。

过程

在此示例中,托管要素图层 (PolygonParcel) 在 ArcGIS Online 中与相关表 (Relate_19543) 一起发布。 要素图层和表均含有一个名为 'FID_Tracts' 的字段,且它们基于该字段相关。 下图显示了 PolygonParcel 要素图层的属性表。 相关记录将以列的形式显示,且在属性表的右侧带有斜体标题。

An image of the feature layer attribute table.

下图显示了相关表 Relate_19543 的属性。 Value1Value2Value3 是包含需要求和并在弹出窗口中显示的值的字段。

An image of the related table attributes.
  1. 在 ArcGIS Online 中,在 Map Viewer 中打开包含相关表的要素图层。
  2. 单击图层的省略号 An image of the ellipsis button. 按钮,然后选择配置弹出窗口
  3. 配置弹出窗口窗格中,根据需要配置弹出窗口设置。 有关详细信息,请参阅配置弹出窗口
  4. 属性表达式部分下,单击添加以创建一个自定义表达式,用于计算相关表中多个属性字段值的总和。
  5. 或者,可单击编辑以根据需要更改默认的自定义字段名称,然后单击保存
  6. 将以下表达式粘贴在表达式框中。 根据使用的数据替换尖括号 < > 中的变量。
var table = FeatureSetByName($datastore,"name of related table>") //reads the related table into a variable
var total = 0 //define a variable for the sum

for (var t in table) {//loop the related table to find the related records for the feature
if (t.the name of the field that the relate is based on> == $feature.the name of the field that the relate is based on>) {
total = total + t. + t. + t.
}
}
return total
下图显示了基于上述要素图层和相关表的已配置表达式。
An image of the custom expression.
  1. 单击确定以应用表达式。
  2. 单击配置弹出窗口窗格中的确定
  3. 单击地图中的任意要素以显示弹出窗口。 相关表的多个属性字段值的计算总和将显示在弹出窗口中。
An image of the pop-up displaying the calculated sum of multiple attribute values from a related table.

文章 ID:000019543

从 ArcGIS 专家处获得帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项