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


JavaScript ArcGIS StatisticDefinition用法及代碼示例


基本信息

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

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

ESM: import StatisticDefinition from "@arcgis/core/rest/support/StatisticDefinition";

類: esri/rest/support/StatisticDefinition

繼承: StatisticDefinition > Accessor

自從:用於 JavaScript 4.0 的 ArcGIS API

用法說明

此類定義用於查詢圖層或圖層視圖以獲取統計信息的參數。

例子:

// query for the sum of the population in all features
let sumPopulation = {
  onStatisticField: "POP_2015",  // service field for 2015 population
  outStatisticFieldName: "Pop_2015_sum",
  statisticType: "sum"
}
let query = layer.createQuery();
query.outStatistics = [ sumPopulation ];
layer.queryFeatures(query)
  .then(function(response){
     let stats = response.features[0].attributes;
     console.log("output stats:", stats);
  });
// query for the average of the population change for all features
let populationChangeDefinition = {
  onStatisticField: "POP_2015 - POP_2010",  // service field for 2015 population
  outStatisticFieldName: "avg_pop_change_2015_2010",
  statisticType: "avg"
}
let query = layer.createQuery();
query.outStatistics = [ populationChangeDefinition ];
layer.queryFeatures(query)
  .then(function(response){
     let stats = response.features[0].attributes;
     console.log("Average change:", stats.avg_pop_change_2015_2010);
  });

相關用法


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