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


JavaScript ArcGIS Query.outFields用法及代码示例


基本信息

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

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

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

类: esri/rest/support/Query

继承: Query > Accessor

自从:用于 JavaScript 4.20 的 ArcGIS API

用法说明

Query.outFields函数(或属性)的定义如下:

outFields String[]


要包含在 FeatureSet 中的属性字段。字段必须存在于服务层中。您必须列出实际的字段名称而不是字段别名。但是,您可以在显示查询结果时使用字段别名。

指定输出字段时,应将字段限制为仅希望在查询或结果中使用的字段。您包含的字段越少,有效负载大小越小,因此查询的响应速度就越快。

您还可以将 SQL 表达式指定为 outFields 以在服务器端计算查询结果的新值。有关此示例,请参阅下面的示例片段。

每个查询都必须有权访问图层的 ShapeObjectId 字段。但是,outFields 列表不需要包括这两个字段。

已知限制

  • 如果在基于要素服务的 FeatureLayer 上将 outFields 指定为表达式,则服务函数 advancedQueryCapabilities.supportsOutFieldSQLExpressionuseStandardizedQueries 必须都为真。

默认值:null

例子:

// query for field attributes
query.outFields = [ "NAME", "STATE_ABBR", "POP04" ];
// query for data returned from an expressions and other fields as the following field names
// POP_CHANGE_2020, NAME, POP2020
// where POP_CHANGE_2020 represents the population change from 2010 - 2020
query.outFields = [ "( (POP2020 - POP2010) / POP2010 ) * 100 as POP_CHANGE_2020", "NAME", "POP2020" ]

相关用法


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