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


JavaScript ArcGIS PopupTemplate.expressionInfos用法及代码示例


基本信息

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

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

ESM: import PopupTemplate from "@arcgis/core/PopupTemplate";

类: esri/PopupTemplate

继承: PopupTemplate > Accessor

自从:用于 JavaScript 4.0 的 ArcGIS API

用法说明

PopupTemplate.expressionInfos函数(或属性)的定义如下:

expressionInfos ExpressionInfo[] autocast


自从:ArcGIS 适用于 JavaScript 4.4 的 API

对象数组或 ExpressionInfo[] 引用 Arcade 表达式,遵循 Arcade Popup Profile 定义的规范。

例子:

// Displays two values returned from Arcade expressions
// in a table within the popup when a feature is clicked
layer.popupTemplate = {
  content: [{
    type: "fields", // Autocasts as new FieldsContent()
    // Autocasts as new FieldInfo[]
    fieldInfos: [{
      fieldName: "expression/college"
    }, {
      fieldName: "expression/nocollege"
    }]
  }],
  // autocasts to ExpressionInfo class
  expressionInfos: [{
    name: "college",
    title: "Completed a college degree",
    expression: "$feature.bachelor + $feature.master + $feature.doctorate"
  }, {
    name: "nocollege",
    title: "Did not complete a college degree",
    expression: "$feature.elementary + $feature.middle + $feature.highschool + $feature.somecollege"
  }]
};
// Displays a value returned from an Arcade expression within
// a simple string defined in the popupTemplate's content
layer.popupTemplate = {
  content: "{expression/per-total}% of people in this boundary have a college education.",
  expressionInfos: [{
    name: "per-total",
    expression: "Round((($feature.bachelor + $feature.master + $feature.doctorate) / $feature.TOT_POP) * 100, 2)"
  }]
};

相关用法


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