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


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。