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


JavaScript ArcGIS Sublayer.definitionExpression用法及代码示例


基本信息

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

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

ESM: import Sublayer from "@arcgis/core/layers/support/Sublayer";

类: esri/layers/support/Sublayer

继承: Sublayer > Accessor

自从:用于 JavaScript 4.1 的 ArcGIS API

用法说明

Sublayer.definitionExpression函数(或属性)的定义如下:

definitionExpression String


用于过滤图像中特征的 SQL where 子句。只有满足定义表达式的特征才会显示在 View 中。定义表达式可以在子图层加载到视图之前或添加到 MapImageLayer 之后构建时设置。要查看是否可以使用此属性,请检查 MapImageLayer.capabilitiessupportsSublayerDefinitionExpression 属性。

例子:

let countiesLyr = layer.sublayers.find(function(sublayer){
  return sublayer.title === "States";
});
countiesLyr.definitionExpression = "STATE = 'Nebraska'"
// add a definition expression to sublayer when
// it is created in MapImageLayer constructor
let layer = new MapImageLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
  sublayers: [{
    id: 0,
    definitionExpression: "STATE = 'Nebraska'"
  }]
});
// Set a definition expression on the sublayer with ID of 0
layer.findSublayerById(0).definitionExpression = "STATE = 'Nebraska'";

相关用法


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