用于在图像上渲染光栅图像的图像图层的有序集合 An ordered collection of imagery layers for rendering raster imagery on a
Globe or Cesium3DTileset.
Scene#imageryLayers用于操纵地球上的图像层。 for manipulating imagery layers on the globe.Cesium3DTileset#imageryLayers用于操作 3D 图块集上的图像层。 for manipulating imagery layers on a 3D tileset.
演示: Demo:
另见: See:
成员 Members
layerAdded : Event
将图层添加到集合时引发的事件。事件处理程序将传递已添加的层及其添加的索引。 An event that is raised when a layer is added to the collection. Event handlers are passed the layer that was added and the index at which it was added.
-
默认值: Default Value:
Event()
layerMoved : Event
当图层在集合中更改位置时引发的事件。事件处理程序将传递已移动的图层、移动后的新索引以及移动前的旧索引。 An event that is raised when a layer changes position in the collection. Event handlers are passed the layer that was moved, its new index after the move, and its old index prior to the move.
-
默认值: Default Value:
Event()
layerRemoved : Event
从集合中删除图层时引发的事件。事件处理程序将传递已删除的层以及从中删除该层的索引。 An event that is raised when a layer is removed from the collection. Event handlers are passed the layer that was removed and the index from which it was removed.
-
默认值: Default Value:
Event()
layerShownOrHidden : Event
通过设置显示或隐藏图层时引发的事件 An event that is raised when a layer is shown or hidden by setting the
ImageryLayer#show 财产。向事件处理程序传递对此层的引用、集合中该层的索引以及一个标志,如果该层现在显示,则该标志为 true;如果该层现在隐藏,则该标志为 false。 property. Event handlers are passed a reference to this layer, the index of the layer in the collection, and a flag that is true if the layer is now shown or false if it is now hidden.
-
默认值: Default Value:
Event()
获取此集合中的层数。 Gets the number of layers in this collection.
方法 Methods
向集合中添加一个图层。 Adds a layer to the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
layer |
ImageryLayer | 要添加的图层。 the layer to add. |
index |
number | 可选 optional 添加图层的索引。如果省略,该图层将添加到所有现有图层的顶部。 the index to add the layer at. If omitted, the layer will be added on top of all existing layers. |
抛出: Throws:
-
DeveloperError :索引(如果提供)必须大于或等于零且小于或等于层数。 : index, if supplied, must be greater than or equal to zero and less than or equal to the number of the layers.
示例: Examples:
const imageryLayer = Cesium.ImageryLayer.fromWorldImagery();
scene.imageryLayers.add(imageryLayer);
const imageryLayer = Cesium.ImageryLayer.fromProviderAsync(Cesium.IonImageryProvider.fromAssetId(3812));
scene.imageryLayers.add(imageryLayer);
addImageryProvider(imageryProvider, index) → ImageryLayer
使用给定的 ImageryProvider 创建一个新图层并将其添加到集合中。 Creates a new layer using the given ImageryProvider and adds it to the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
imageryProvider |
ImageryProvider | 要为其创建新图层的图像提供者。 the imagery provider to create a new layer for. |
index |
number | 可选 optional 添加图层的索引。如果省略,该图层将添加到所有现有图层的顶部。 the index to add the layer at. If omitted, the layer will added on top of all existing layers. |
返回: Returns:
新创建的图层。 The newly created layer.
示例: Example:
try {
const provider = await Cesium.IonImageryProvider.fromAssetId(3812);
scene.imageryLayers.addImageryProvider(provider);
} catch (error) {
console.log(`There was an error creating the imagery layer. ${error}`)
}
检查集合是否包含给定图层。 Checks to see if the collection contains a given layer.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
layer |
ImageryLayer | 要检查的图层。 the layer to check for. |
返回: Returns:
如果集合包含图层,则为 true,否则为 false。 true if the collection contains the layer, false otherwise.
销毁该集合中所有图层所持有的 WebGL 资源。显式销毁此对象可以确定性地释放 WebGL 资源,而不是依赖垃圾收集器。 Destroys the WebGL resources held by all layers in this collection. Explicitly destroying this object allows for deterministic release of WebGL resources, instead of relying on the garbage collector.
一旦该对象被销毁,就不应再使用;调用除 Once this object is destroyed, it should not be used; calling any function other than
一旦该对象被销毁,就不应再使用;调用除 Once this object is destroyed, it should not be used; calling any function other than
isDestroyed 将导致 will result in a DeveloperError 例外。因此,分配返回值( exception. Therefore, assign the return value (undefined) 到对象,如示例中所做的那样。 ) to the object as done in the example.
抛出: Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
示例: Example:
layerCollection = layerCollection && layerCollection.destroy();
另见: See:
从集合中按索引获取图层。 Gets a layer by index from the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
index |
number | 要检索的索引。 the index to retrieve. |
返回: Returns:
给定索引处的图像图层。 The imagery layer at the given index.
确定集合中给定图层的索引。 Determines the index of a given layer in the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
layer |
ImageryLayer | 要查找索引的图层。 The layer to find the index of. |
返回: Returns:
The index of the layer in the collection, or -1 if the layer does not exist in the collection.
如果该对象被销毁则返回 true;否则为假。 Returns true if this object was destroyed; otherwise, false.
如果该对象被破坏,则不应使用它;调用除 If this object was destroyed, it should not be used; calling any function other than
如果该对象被破坏,则不应使用它;调用除 If this object was destroyed, it should not be used; calling any function other than
isDestroyed 将导致 will result in a DeveloperError exception.
返回: Returns:
如果该对象被销毁,则为 true;否则为假。 true if this object was destroyed; otherwise, false.
另见: See:
将集合中的图层降低一个位置。 Lowers a layer down one position in the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
layer |
ImageryLayer | 要移动的图层。 the layer to move. |
抛出: Throws:
-
DeveloperError : layer is not in this collection.
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
将图层降低到集合的底部。 Lowers a layer to the bottom of the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
layer |
ImageryLayer | 要移动的图层。 the layer to move. |
抛出: Throws:
-
DeveloperError : layer is not in this collection.
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
pickImageryLayerFeatures(ray, scene) → Promise.<Array.<ImageryLayerFeatureInfo>>|undefined
异步确定与拾取射线相交的影像图层要素。通过调用找到相交的图像层特征 Asynchronously determines the imagery layer features that are intersected by a pick ray. The intersected imagery layer features are found by invoking
ImageryProvider#pickFeatures 对于与拾取光线相交的每个图像层图块。要计算来自屏幕上某个位置的拾取射线,请使用 for each imagery layer tile intersected by the pick ray. To compute a pick ray from a location on the screen, use Camera.getPickRay.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
ray |
Ray | 用于测试相交的光线。 The ray to test for intersection. |
scene |
Scene | 现场。 The scene. |
返回: Returns:
解析为由拾取射线相交的一系列特征的承诺。如果可以快速确定没有要素相交(例如,因为没有活动图像提供者支持 A promise that resolves to an array of features intersected by the pick ray. If it can be quickly determined that no features are intersected (for example, because no active imagery providers support
ImageryProvider#pickFeatures
或者因为拾取射线不与表面相交),该函数将返回 undefined。 or because the pick ray does not intersect the surface), this function will return undefined.
示例: Example:
const pickRay = viewer.camera.getPickRay(windowPosition);
const featuresPromise = viewer.imageryLayers.pickImageryLayerFeatures(pickRay, viewer.scene);
if (!Cesium.defined(featuresPromise)) {
console.log('No features picked.');
} else {
Promise.resolve(featuresPromise).then(function(features) {
// This function is called asynchronously when the list if picked features is available.
console.log(`Number of features: ${features.length}`);
if (features.length > 0) {
console.log(`First feature name: ${features[0].name}`);
}
});
}
pickImageryLayers(ray, scene) → Array.<ImageryLayer>|undefined
确定与拾取射线相交的影像图层。要计算来自屏幕上某个位置的拾取射线,请使用 Determines the imagery layers that are intersected by a pick ray. To compute a pick ray from a location on the screen, use
Camera.getPickRay.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
ray |
Ray | 用于测试相交的光线。 The ray to test for intersection. |
scene |
Scene | 现场。 The scene. |
返回: Returns:
包含与给定拾取射线相交的所有层的数组。如果未选择任何图层,则未定义。 An array that includes all of the layers that are intersected by a given pick ray. Undefined if no layers are selected.
在集合中将图层提升一个位置。 Raises a layer up one position in the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
layer |
ImageryLayer | 要移动的图层。 the layer to move. |
抛出: Throws:
-
DeveloperError : layer is not in this collection.
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
将图层提升到集合的顶部。 Raises a layer to the top of the collection.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
layer |
ImageryLayer | 要移动的图层。 the layer to move. |
抛出: Throws:
-
DeveloperError : layer is not in this collection.
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
从此集合中删除图层(如果存在)。 Removes a layer from this collection, if present.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
layer |
ImageryLayer | 要删除的层。 The layer to remove. | |
destroy |
boolean |
true
|
可选 optional 除了移除图层之外是否还破坏图层。 whether to destroy the layers in addition to removing them. |
返回: Returns:
如果图层位于集合中并已被删除,则为 true;如果图层不在集合中,则为 false。 true if the layer was in the collection and was removed, false if the layer was not in the collection.
从此集合中删除所有图层。 Removes all layers from this collection.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
destroy |
boolean |
true
|
可选 optional 除了移除图层之外是否还破坏图层。 whether to destroy the layers in addition to removing them. |
