當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


JavaScript ArcGIS ElementExpressionInfo.expression用法及代碼示例


基本信息

以下是所在類或對象的基本信息。

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

用法說明

ElementExpressionInfo.expression函數(或屬性)的定義如下:

expression String


Arcade 表達式計算為字典。字典必須表示 TextContentFieldsContentMediaContent 彈出內容元素,如 Popup Element web map specification 中定義的那樣。

此表達式可以使用 $feature$layer$map$datastore 全局變量從Map或數據存儲中的要素、其圖層或其他圖層訪問數據值。有關有效返回字典的更多信息和示例,請參閱Popup Element Arcade Profile 規範。

例子:

// Creates an column chart where each category/value
// is an aggregate of two or more fields
layer.popupTemplate = {
  title: "Educational Attainment",
  content: [{
    type: "expression",
    expressionInfo: {
      expression: `
        // Create a dictionary of attributes representing the values
        // to display in the table
        var attributes = {
          "No School": $feature.no_school + $feature.some_primary,
          "Primary": $feature.primary_complete + $feature.some_secondary,
          "Secondary": $feature.secondary_complete + $feature.some_highSchool,
          "High School": $feature.highSchool_diploma + $feature.highSchool_ged + $feature.some_college,
          "College/University": $feature.associates + $feature.bachelors + $feature.masters + $feature.doctorate + $feature.professional;
        };

        var fieldInfos = [];

        // Create an array representing the attribute names (or keys)
        // to include in the chart
        for (var k in attributes){
          Push(fieldInfos, {
            fieldName: k
          });
        }

        // Returns a dictionary providing the information
        // required by the popup to render a table of key value pairs
        return {
          type: "media",
          attributes: attributes,
          // The list of attribute names (keys) to include in the table
          fieldInfos: fieldInfos
        };
      `,
      title: "Educational Attainment"
    }
  }]
};

相關用法


注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 ElementExpressionInfo.expression。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。