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


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。