基本信息
以下是所在類或對象的基本信息。
AMD:
require(["esri/layers/BaseElevationLayer"], (BaseElevationLayer) => { /* code goes here */ });
ESM:
import BaseElevationLayer from "@arcgis/core/layers/BaseElevationLayer";
類:
esri/layers/BaseElevationLayer
繼承: BaseElevationLayer > Layer > Accessor
自從:用於 JavaScript 4.4 的 ArcGIS API
用法說明
BaseElevationLayer 旨在擴展以創建自定義高程圖層。您可以通過在 BaseElevationLayer
上調用 createSubclass() 來創建自定義 ElevationLayer。
如果新層需要獲取和準備資源,您可以在加載層之前異步初始化屬性。這是在 load() 方法中處理的。當圖層即將顯示時,此方法將由您或視圖調用一次。在方法主體中,您可以調用addResolvingPromise()來添加一個承諾,該承諾必須在該層被視為已加載之前解決。
您必須覆蓋 fetchTile() 方法中的邏輯才能返回自定義高程數據的值。這樣做可以誇大實際高程值或將專題數據映射為高程圖層。轉換高程數據值時,建議保持無數據值不變。
const ExaggeratedElevationLayer = BaseElevationLayer.createSubclass({
load: function() {
// add loadable dependencies here and include
// their returned promises in the
// addResolvingPromise() method
this._elevation = new ElevationLayer({
url: "//elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"
});
this.addResolvingPromise(this._elevation.load());
},
fetchTile: function(level, row, col, options) {
// must resolve to an object with the following properties:
// values <number[]>: an array of elevation values for each pixel
// width <number>: the width of the tile in pixels
// height <number>: the height of the tile in pixels
// noDataValue <number>: value of pixels where no elevation data is present
return this._elevation.fetchTile(level, row, col, options).then(function(data) {
let exaggeration = this.exaggeration;
// `data` is an object that contains the width of the tile in pixels,
// the height of the tile in pixels, and the values of each pixel
for (let i = 0; i < data.values.length; i++) {
// each value represents an elevation sample for the
// given pixel position in the tile
// check if the value is a no data value
if (data.values[i] !== data.noDataValue) {
// multiply the elevation value by the exaggeration value
data.values[i] *= exaggeration;
}
}
return data;
}.bind(this))
}
});
創建圖層後,您必須將其添加到 Map.ground 屬性的圖層,並將Map添加到 SceneView 實例。
let map = new Map({
basemap: "satellite",
ground: {
layers: [ new ExaggeratedElevationLayer() ]
}
});
sceneView.map = map;
相關用法
- JavaScript ArcGIS BaseElevationLayer.when用法及代碼示例
- JavaScript ArcGIS BaseElevationLayer.addResolvingPromise用法及代碼示例
- JavaScript ArcGIS BaseElevationLayer layerview-create事件用法及代碼示例
- JavaScript ArcGIS BaseElevationLayer.opacity用法及代碼示例
- JavaScript ArcGIS BaseElevationLayer.on用法及代碼示例
- JavaScript ArcGIS BaseElevationLayer layerview-create-error事件用法及代碼示例
- JavaScript ArcGIS BaseElevationLayer.visible用法及代碼示例
- JavaScript ArcGIS BaseElevationLayer.fullExtent用法及代碼示例
- JavaScript ArcGIS BaseLayerViewGL2D.render用法及代碼示例
- JavaScript ArcGIS BasemapGallery.visible用法及代碼示例
- JavaScript ArcGIS BaseLayerViewGL2D.requestRender用法及代碼示例
- JavaScript ArcGIS BaseTileLayer.maxScale用法及代碼示例
- JavaScript ArcGIS Basemap.fromId用法及代碼示例
- JavaScript ArcGIS BaseDynamicLayer layerview-create事件用法及代碼示例
- JavaScript ArcGIS BasemapToggle.visibleElements用法及代碼示例
- JavaScript ArcGIS BasemapLayerList.headingLevel用法及代碼示例
- JavaScript ArcGIS BaseDynamicLayer.addResolvingPromise用法及代碼示例
- JavaScript ArcGIS BaseTileLayer.effect用法及代碼示例
- JavaScript ArcGIS BaseLayerView2D用法及代碼示例
- JavaScript ArcGIS BaseTileLayer.addResolvingPromise用法及代碼示例
- JavaScript ArcGIS BaseTileLayer layerview-create事件用法及代碼示例
- JavaScript ArcGIS BaseTileLayer.on用法及代碼示例
- JavaScript ArcGIS BaseDynamicLayer.fetchImage用法及代碼示例
- JavaScript ArcGIS BasemapGallery.when用法及代碼示例
- JavaScript ArcGIS BaseDynamicLayer.minScale用法及代碼示例
注:本文由純淨天空篩選整理自arcgis.com大神的英文原創作品 BaseElevationLayer。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。