ImageryLayerCollection

Members

将图层添加到集合时引发的事件。 事件处理程序将传递给 和添加它的索引。
Default Value: Event()
当图层在集合中的位置发生变化时引发的事件。 事件处理程序将传递给 已移动,移动后的新索引和移动前的旧索引。
Default Value: Event()
从集合中删除图层时引发的事件。 事件处理程序将传递给 已删除,并从中删除了该索引。
Default Value: Event()
通过设置 ImageryLayer#show 属性。 事件处理程序将传递对此层的引用 集合中层的索引,以及一个标志(如果层现在为 true) 显示或 false(如果现在隐藏)。
Default Value: Event()
获取此集合中的层数。

Methods

向集合添加图层。
Name Type Description
layer ImageryLayer 要添加的图层。
index number optional 要添加层的索引。 如果省略,图层将 添加到所有现有图层的顶部。
Throws:
  • DeveloperError : 索引(如果提供)必须大于或等于零且小于或等于层数。
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:
Example:
layerCollection = layerCollection && layerCollection.destroy();
See:
从集合中按索引获取层。
Name Type Description
index number 要检索的索引。
Returns:
位于给定索引处的影像图层。
确定集合中给定图层的索引。
Name Type Description
layer ImageryLayer 要查找其索引的图层。
Returns:
集合中图层的索引,如果集合中不存在该图层,则为 -1。
如果此对象已销毁,则返回 true;否则为 false。

如果此对象已销毁,则不应使用;调用 isDestroyed 将导致 DeveloperError 异常。
Returns:
true,如果此对象被销毁;否则为 false。
See:
将图层在集合中降低一个位置。
Name Type Description
layer ImageryLayer 指定要移动的图层。
Throws:
将图层降低到集合的底部。
Name Type Description
layer ImageryLayer 指定要移动的图层。
Throws:

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

确定与拾取光线相交的图像图层。要从 location,请使用 Camera.getPickRay
Name Type Description
ray Ray 用于测试交集的射线。
scene Scene 场景。
Returns:
一个包含所有 与给定拾取光线相交的图层。未定义的 if 未选择任何图层。
将图层在集合中提升一个位置。
Name Type Description
layer ImageryLayer 指定要移动的图层。
Throws:
将图层提升到集合的顶部。
Name Type Description
layer ImageryLayer 指定要移动的图层。
Throws:

remove(layer, destroy)boolean

从此集合中删除图层(如果存在)。
Name Type Default Description
layer ImageryLayer 要删除的图层。
destroy boolean true optional 是否除了删除图层之外还要销毁图层。
Returns:
true,如果图层位于集合中并被删除, 如果图层不在集合中,则为 false。
从此集合中删除所有图层。
Name Type Default Description
destroy boolean true optional 是否除了删除图层之外还要销毁图层。
Need help? The fastest way to get answers is from the community and team on the Cesium Forum.