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


JavaScript ArcGIS TopFilter用法及代碼示例


基本信息

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

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

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

類: esri/rest/support/TopFilter

繼承: TopFilter > Accessor

自從:用於 JavaScript 4.20 的 ArcGIS API

用法說明

此類定義了頂級過濾器參數,用於對 FeatureLayer 中的要素執行頂級要素查詢。在函數層上調用任何頂級查詢方法時,必須在 TopFeaturesQuery 對象上設置此參數。它用於設置 top 特征查詢使用的 groupByFields、orderByFields 和計數條件。例如,您可以使用FeatureLayer的queryTopFeatures()方法查詢美國每個州人口最多的三個縣。

// query the top three most populous counties from each state.
// Results will be ordered based the population of each county in descending order
// top query will run against all features available in the service
const query = new TopFeaturesQuery({
  outFields: ["State, Pop_total, County"],
  topFilter: new TopFilter({
    topCount: 3,
    groupByFields: ["State"],
    orderByFields: ["Pop_total DESC"]
  })
});
featureLayer.queryTopFeatures(query)
  .then(function(response){
     // returns a feature set with features containing the most populous
     // three counties in each state ordered by the number of population.
     // The following attributes are returned as well: State, Pop_total, County
   });

相關用法


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