当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


JavaScript ArcGIS ElementExpressionInfo用法及代码示例


基本信息

以下是所在类或对象的基本信息。

AMD: require(["esri/popup/ElementExpressionInfo"], (ElementExpressionInfo) => { /* code goes here */ });

ESM: import ElementExpressionInfo from "@arcgis/core/popup/ElementExpressionInfo";

类: esri/popup/ElementExpressionInfo

继承: ElementExpressionInfo > Accessor

自从:用于 JavaScript 4.22 的 ArcGIS API

用法说明

定义用于在 PopupTemplate 中创建 ExpressionContent 元素的 Arcade 表达式。表达式必须计算为 dictionary ,表示 TextContentFieldsContentMediaContent 弹出元素,如 Popup Element web map specification 中定义。

此表达式可以使用 $feature$layer$map$datastore 全局变量从Map或数据存储中的要素、其图层或其他图层访问数据值。有关有效返回字典的更多信息和示例,请参阅Popup Element Arcade Profile 规范。

例子:

// Creates an ordered list in a cluster's popup
// listing the type of fuel used to generate power in the cluster
// ordered by the total number of power plants for each fuel type.
layer.featureReduction = {
  type: "cluster",
  popupTemplate: {
    title: "Power plant summary",
    content: [{
      type: "expression",
      expressionInfo: {
        expression: `
          // Specify which fields are required by the expression
          Expects($aggregatedFeatures, "fuel1", "capacity_mw")

          // Query stats for each fuel type
          var statsFS = GroupBy($aggregatedFeatures,
            [
              { name: 'Type', expression: 'fuel1'},
            ],
            [  // statistics to return for each unique category
              { name: 'capacity_total', expression: 'capacity_mw', statistic: 'SUM' },
              { name: 'capacity_max', expression: 'capacity_mw', statistic: 'MAX' },
              { name: 'num_features', expression: '1', statistic: 'COUNT' }
            ]
          );
          // create an list in descending order based
          // on the number of plants for each fuel type.
          var ordered = OrderBy(statsFs, 'num_features DESC');

          var list = "<ol>";

          for (var group in ordered){
            list += \`<li>\${group.Type} (\${Text(group.num_features, "#,###")})</li>\`
          }
          list += "</ol>";

          // The return dictionary must return a text, fields, or media
          // popup element as defined in the web map specification
          return {
            type: "text",
            text: list
          }
        `,
        title: "List of fuel types"
      }
    }]
  }
};

相关用法


注:本文由纯净天空筛选整理自arcgis.com大神的英文原创作品 ElementExpressionInfo。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。