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


JavaScript ArcGIS WebScene.load用法及代碼示例

基本信息

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

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

ESM: import WebScene from "@arcgis/core/WebScene";

類: esri/WebScene

繼承: WebScene > Map > Accessor

自從:用於 JavaScript 4.0 的 ArcGIS API

用法說明

WebScene.load函數(或屬性)的定義如下:

load () {Promise}


觸發加載WebScene 實例。

當 WebScene 的操作圖層、底圖和地麵完全創建後,即被視為已加載。當使用 PortalItem 創建時,load() 將首先獲取其數據來創建內容,否則會立即解析。

當WebScene 實例添加到其map 屬性時,SceneView 會自動調用load() 方法,以便它可以顯示在視圖中並加載每個單獨的圖層。如果 WebScene 在視圖之外使用,例如預加載它,則必須顯式調用 load() 以與其資源交互。

返回:

類型 說明
Promise 當加載 WebScene 時解決。

例子:

// programmatically load all the layers
require([
  "esri/WebScene"
], function(
  WebScene
) {

  const scene = new WebScene({
    portalItem: {
      id: "affa021c51944b5694132b2d61fe1057"
    }
  });

  scene.load()
    .then(function() {
      // load the basemap to get its layers created
      return scene.basemap.load();
    })
    .then(function() {
      // grab all the layers and load them
      const allLayers = scene.allLayers;
      const promises = allLayers.map(function(layer) {
        return layer.load();
      });
      return Promise.all(promises.toArray());
    })
    .then(function(layers) {
      // each layer load promise resolves with the layer
      console.log("all " + layers.length + " layers loaded");
    })
    .catch(function(error) {
      console.error(error);
    });
});

相關用法


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