ImageryLayerCollection

Members

将层添加到集合时引发的事件。事件处理程序被传递到 以及添加它的索引。
Default Value: Event()
层在集合中更改位置时引发的事件。事件处理程序被传递到 被移动,它的新索引在移动之后,它的旧索引在移动之前。
Default Value: Event()
从集合中移除层时引发的事件。事件处理程序被传递到 以及从中删除的索引。
Default Value: Event()
当层显示或隐藏时引发的事件 ImageryLayer#show财产。向事件处理程序传递对此层的引用, 集合中层的索引,以及如果层现在为true的标志 如果现在隐藏,则显示或错误。
Default Value: Event()
获取此集合中的层数。

Methods

向集合中添加层。
Name Type Description
layer ImageryLayer 要添加的层。
index Number optional 要在处添加层的索引。如果省略,层将 添加到所有现有层的顶部。
Throws:
  • DeveloperError :索引(如果提供)必须大于或等于零且小于或等于层数。

addImageryProvider(imageryProvider, index)ImageryLayer

使用给定的ImageryProvider创建新层并将其添加到集合中。
Name Type Description
imageryProvider ImageryProvider 要为其创建新层的图像提供程序。
index Number optional 要在处添加层的索引。如果省略,层将 添加到所有现有层的顶部。
Returns:
新创建的层。

contains(layer)Boolean

检查集合是否包含给定层。
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:
给定索引处的图像层。

indexOf(layer)Number

确定集合中给定层的索引。
Name Type Description
layer ImageryLayer 要查找其索引的层。
Returns:
集合中层的索引,如果集合中不存在该层,则为-1。

isDestroyed()Boolean



如果此对象已销毁,则返回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:
一个由一个特征相交的射线阵列。 如果可以快速确定没有要素相交(例如, 因为没有活动图像提供商支持ImageryProvider#pickFeatures 或者因为拾取光线不与曲面相交),此函数将 返回未定义。
Example:
var pickRay = viewer.camera.getPickRay(windowPosition);
var featuresPromise = viewer.imageryLayers.pickImageryLayerFeatures(pickRay, viewer.scene);
if (!Cesium.defined(featuresPromise)) {
    console.log('No features picked.');
} else {
    Cesium.when(featuresPromise, 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);
        }
    });
}
在集合中向上提升一个层。
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:
如果层在集合中并被移除, 如果层不在集合中,则为false。
删除此集合中的所有图层。
Name Type Default Description
destroy Boolean true optional 是否除了删除图层之外还要销毁图层。