Members
layerAdded : Event
当层被添加到集合时引发的事件。事件处理程序接收被添加的层和添加位置的索引。
-
Default Value:
Event()
layerMoved : Event
当层在集合中位置发生变化时引发的事件。事件处理程序接收被移动的层、移动后的新索引和移动前的旧索引。
-
Default Value:
Event()
layerRemoved : Event
当层从集合中移除时引发的事件。事件处理程序接收被移除的层和移除位置的索引。
-
Default Value:
Event()
layerShownOrHidden : Event
当层通过设置
ImageryLayer#show 属性被显示或隐藏时引发的事件。事件处理程序接收对该层的引用、
在集合中的索引,以及一个标志,该标志为 true 表示层现在显示,为 false 表示层现在隐藏。
-
Default Value:
Event()
获取此集合中的层数量。
Methods
将一个图层添加到集合中。
| Name | Type | Description |
|---|---|---|
layer |
ImageryLayer | 要添加的图层。 |
index |
number | optional 添加图层的索引。如果省略,则图层将 被添加到所有现有图层之上。 |
Throws:
-
DeveloperError : 如果提供 index,则必须大于等于零且小于等于层的数量。
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 创建一个新图层并将其添加到集合中。
| Name | Type | Description |
|---|---|---|
imageryProvider |
ImageryProvider | 要为其创建新图层的图像提供者。 |
index |
number | optional 添加图层的索引。如果省略,则图层将 添加到所有现有图层之上。 |
Returns:
新创建的图层。
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}`)
}
检查集合中是否包含给定的图层。
| Name | Type | Description |
|---|---|---|
layer |
ImageryLayer | 要检查的图层。 |
Returns:
如果集合包含该图层则返回 true,否則返回 false。
销毁此集合中所有层持有的 WebGL 资源。显式销毁此对象允许确定性地释放
WebGL 资源,而不是依赖垃圾收集器。
一旦此对象被销毁,就不应再使用它;调用除
一旦此对象被销毁,就不应再使用它;调用除
isDestroyed 之外的任何函数
将导致 DeveloperError 异常。因此,将返回值(undefined)分配给对象,如示例中所示。
Throws:
-
DeveloperError : 此对象已被销毁,即已调用 destroy()。
Example:
layerCollection = layerCollection && layerCollection.destroy();
See:
从集合中根据索引获取一个图层。
| Name | Type | Description |
|---|---|---|
index |
number | 要检索的索引。 |
Returns:
在给定索引处的图像层。
确定集合中给定图层的索引。
| Name | Type | Description |
|---|---|---|
layer |
ImageryLayer | 要查找索引的图层。 |
Returns:
图层在集合中的索引,如果图层不存在于集合中则返回 -1。
Returns:
如果此对象已被销毁,则返回 true;否则返回 false。
将图层在集合中下移一个位置。
| Name | Type | Description |
|---|---|---|
layer |
ImageryLayer | 要移动的图层。 |
Throws:
-
DeveloperError : 图层不在此集合中。
-
DeveloperError : 此对象已被销毁,即已调用 destroy()。
将图层降低到集合的底部。
| Name | Type | Description |
|---|---|---|
layer |
ImageryLayer | 要移动的图层。 |
Throws:
-
DeveloperError : 图层不在此集合中。
-
DeveloperError : 此对象已被销毁,即已调用 destroy()。
pickImageryLayerFeatures(ray, scene) → Promise.<Array.<ImageryLayerFeatureInfo>>|undefined
异步确定与拾取光线相交的图像图层特征。通过对每个与拾取光线相交的图像层瓦片调用
ImageryProvider#pickFeatures
来找到相交的图像层特征。要从屏幕上的位置计算拾取光线,请使用 Camera.getPickRay。
| Name | Type | Description |
|---|---|---|
ray |
Ray | 要测试相交的光线。 |
scene |
Scene | 场景。 |
Returns:
一个 Promise,解析为与拾取光线相交的特征数组。
如果可以快速确定没有特征相交(例如,因为没有活动的图像提供者支持
ImageryProvider#pickFeatures 或因为拾取光线未与表面相交),
此函数将返回 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
确定与拾取光线相交的图像层。要从屏幕上的位置计算拾取光线,请使用
Camera.getPickRay。
| Name | Type | Description |
|---|---|---|
ray |
Ray | 要测试相交的光线。 |
scene |
Scene | 场景。 |
Returns:
包含所有与给定拾取光线相交的层的数组。如果没有选定任何层,则返回 undefined。
raise(index) → ImageryLayer
从集合中根据索引获取一个图层。
| Name | Type | Description |
|---|---|---|
index |
number | 要检索的索引。 |
Returns:
在给定索引处的图像层。
将图层提升到集合的顶部。
| Name | Type | Description |
|---|---|---|
layer |
ImageryLayer | 要移动的图层。 |
Throws:
-
DeveloperError : 图层不在此集合中。
-
DeveloperError : 此对象已被销毁,即已调用 destroy()。
从此集合中移除一个图层(如果存在)。
| Name | Type | Default | Description |
|---|---|---|---|
layer |
ImageryLayer | 要移除的图层。 | |
destroy |
boolean |
true
|
optional 移除图层的同时是否销毁它们。 |
Returns:
如果图层在集合中并被移除,则返回 true;
如果图层不在集合中,则返回 false。
从此集合中移除所有图层。
| Name | Type | Default | Description |
|---|---|---|---|
destroy |
boolean |
true
|
optional 移除图层的同时是否销毁它们。 |
