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


JavaScript ArcGIS MapImageLayer.sublayers用法及代碼示例


基本信息

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

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

ESM: import MapImageLayer from "@arcgis/core/layers/MapImageLayer";

類: esri/layers/MapImageLayer

繼承: MapImageLayer > Layer > Accessor

自從:用於 JavaScript 4.0 的 ArcGIS API

用法說明

MapImageLayer.sublayers函數(或屬性)的定義如下:

來自 Object[]

Collection of Sublayer 對象,允許您更改 MapImageLayer 的一個或多個子圖層的屬性。如果未指定此屬性,則服務中的所有子圖層都將按照服務中的定義顯示。如果將一個空數組傳遞給此屬性,則服務中的任何子圖層都不會顯示在圖層中。

所有子圖層都按照它們在視圖中的繪製順序(從下到上)進行引用。它們可能是 addedremovedreordered 使用 Collection 方法。因為 Sublayer 擴展了 Accessor ,所以它的屬性可能是 watched

例子:

// Only includes the first sublayer from the map service
let layer = new MapImageLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
  sublayers: [{
    id: 0
  }]
});
// toggles the visibility of the first sublayer to false
layer.findSublayerById(0).visible = false;
// sublayers from the service are excluded from the layer
layer = new MapImageLayer({
  url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer",
  sublayers: []
});
// Moves the cities sublayer from index 3 to index 0.
let citiesLayer = layer.sublayers.getItemAt(3);
layer.sublayers.reorder(citiesLayer, 0);
// Overrides the drawing info on the layer with a custom renderer
let citiesLayer = layer.sublayers.getItemAt(3);
citiesLayer.renderer = {
  type: "simple",  // autocasts as new SimpleRenderer()
  symbol: {
    type: "simple-marker",  // autocasts as new SimpleMarkerSymbol()
    color: "blue",
    size: 3
  }
};

相關用法


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