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


JavaScript ArcGIS Sublayer.id用法及代碼示例


基本信息

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

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.id函數(或屬性)的定義如下:

id Number


子層的層 ID。當圖層上未定義源時,該值表示Map服務定義的子圖層的 id。如果創建DynamicDataLayer或MapDataLayer並將其添加到子圖層的源屬性中,則該屬性的值可以是開發人員設置的任何值。

例子:

// Creates a MapImageLayer instance containing only the sublayers defined below.
let layer = new MapImageLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
  // this service has four sublayers, but we're only going to include three.
  sublayers: [ { id: 2 }, { id: 1 }, { id: 0 } ]
});
// Creates a MapImageLayer instance containing only the sublayers defined below.
let layer = new MapImageLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
  sublayers: [{ // sets a new renderer on this sublayer
    id: 2,
    renderer: {
      type: "class-breaks"  // autocasts as new ClassBreaksRenderer()
      // set renderer properties here
    }
  }, { // sets new labelingInfo on the sublayer
    id: 1,
    labelingInfo: [ new LabelClass( ... ) ]
  }, { // retains properties defined by the service, but makes sublayer not visible
    id: 0,
    visible: false
  }]
});

相關用法


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