基本信息
以下是所在类或对象的基本信息。
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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。