Class: ImageryLayerCollection

ImageryLayerCollection

new ImageryLayerCollection()

影像图层集合类。
该类主要用于对影像类图层进行管理。

Members

layerAddedEvent

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()

layerMovedEvent

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()

layerRemovedEvent

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()

layerShownOrHiddenEvent

An event that is raised when a layer is shown or hidden by setting the ImageryLayer#show 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()

lengthNumber

获取图层集合中的图层数量。

Methods

add(layer, index)

向图层集合添加一个图层。

Name Type Description
layer ImageryLayer

待添加的图层。

index Number 可选

待添加图层的索引。

Throws:

索引值应大于等于0,且小于图层总数量。

Type
DeveloperError

addGridProvider(gridProvider, index){GridLayer}

添加Grid瓦片服务提供者。

Name Type Description
gridProvider String

通过给定的栅格图层提供者新建图层,将其添加至图层集合中。

index Number 可选

待添加图层的索引(如果忽略,则新增的图层将位于所有已存在的图层之上)。

Returns:
Type Description
GridLayer 新增加的图层。

addImageryProvider(imageryProvider, index){ImageryLayer}

通过给定的影像服务提供者新建图层,将其添加至图层集合中。

Name Type Description
imageryProvider ImageryProvider

指定的影像服务提供者。

index Number 可选

待添加图层的索引。

Returns:
Type Description
ImageryLayer 新创建的影像图层。
Example
var imageryLayers = viewer.imageryLayers;
var labelImagery = new SuperMap3D.WebMapTileServiceImageryProvider({
    url : 'http://[subdomain].tianditu.com/cia_w/wmts',
    layer : 'cia',
    style : 'default',
    format : 'tiles',
    tileMatrixSetID : 'w',
    credit : new SuperMap3D.Credit('天地图全球影像中文注记服务'),
    subdomains : ['t0','t1','t2','t3','t4','t5','t6','t7']
    });
    imageryLayers.addImageryProvider(labelImagery);.

contains(layer){Boolean}

判断图层集合中是否包含指定图层。

Name Type Description
layer ImageryLayer

待检查的图层。

Returns:
Type Description
Boolean 集合中包含该图层返回true,否则返回false。

destroy(){undefined}

释放集合中所有图层占用的WebGL资源。一旦释放对象所占用的资源,该对象将不能被使用,调用任何isDestroyed外的命令将抛出DeveloperError异常。因此,如示例所示,对象分配未定义的返回值。

See:
Throws:

对象被释放。

Type
DeveloperError
Returns:
Type Description
undefined 返回undefined。
Example
layerCollection = layerCollection && layerCollection.destroy();

get(index){ImageryLayer}

获取图层集合中指定索引的影像图层对象。

Name Type Description
index Number

索引值。

Returns:
Type Description
ImageryLayer 影像图层对象。

indexOf(layer){Number}

获取指定图层在图层集合中的索引值。

Name Type Description
layer ImageryLayer

指定的图层。

Returns:
Type Description
Number 图层索引值,若不存在则返回-1。

isDestroyed(){Boolean}

如果对象被释放,返回真,否则返回false。一旦释放对象所占用的资源,该对象将不能被使用,调用任何isDestroyed外的命令将抛出DeveloperError异常。

See:
Returns:
Type Description
Boolean 如果对象被释放,返回真,否则返回false。

lower(layer)

将此图层集合中指定图层往下移动一层。

Name Type Description
layer ImageryLayer

待移动的图层。

Throws:
  • 图层集合中不存在该图层。

    Type
    DeveloperError
  • 对象被释放。

    Type
    DeveloperError

lowerToBottom(layer)

将此图层集合中指定图层移动到最底层。

Name Type Description
layer ImageryLayer

待移动的图层。

Throws:
  • 图层集合中不存在该图层。

    Type
    DeveloperError
  • 对象被释放。

    Type
    DeveloperError

pickImageryLayerFeatures(ray, scene){Promise.<Array.<ImageryLayerFeatureInfo>>|undefined}

通过拾取光标异步选择图层特征。通过援引ImageryProvider#pickFeatures,拾取光标与图层瓦片相交,发现相交的图层特征。使用Camera.getPickRay,从屏幕位置计算拾取光标。

Name Type Description
ray Ray

检测相交的光标。

scene Scene

场景对象。

Returns:
Type Description
Promise.<Array.<ImageryLayerFeatureInfo>> | undefined 通过拾取光标相交获取一组特征的promise。如果能够快速确定没有相交的特征(例如,没有激活的图层支持ImageryProvider#pickFeatures,或拾取光标与图层不相交),则函数返回未定义。
Example
var pickRay = viewer.camera.getPickRay(windowPosition);
var featuresPromise = viewer.imageryLayers.pickImageryLayerFeatures(pickRay, viewer.scene);
if (!SuperMap3D.defined(featuresPromise)) {
    console.log('No features picked.');
} else {
    SuperMap3D.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);
        }
    });
}

raise(layer)

将此图层集合中指定图层往上移动一层。

Name Type Description
layer ImageryLayer

待移动的图层。

Throws:
  • 图层集合中不存在该图层。

    Type
    DeveloperError
  • 对象被释放。

    Type
    DeveloperError

raiseToTop(layer)

将此图层集合中指定图层移动到最顶层。

Name Type Description
layer ImageryLayer

待移动的图层。

Throws:
  • 图层集合中不存在该图层。

    Type
    DeveloperError
  • 对象被释放。

    Type
    DeveloperError

remove(layer, destroy){Boolean}

移除集合中的一个图层。

Name Type Default Description
layer ImageryLayer

待移除的图层。

destroy Boolean true 可选

移除时是否释放资源。

Returns:
Type Description
Boolean 移除成功返回true,否则返回false。

removeAll(destroy)

移除图层集合中的所有图层。

Name Type Default Description
destroy Boolean true 可选

移除时是否释放资源。

removeImageryLayerById(id, destroy)

根据图层ID移除集合中对应的影像图层。

Name Type Default Description
id Number

影像图层的ID。

destroy Boolean true 可选

是否销毁,返回值为flag,表示是否移除成功。

removeImageryLayerByName(name, destroy)

根据图层名称移除集合中对应的影像图层。

Name Type Default Description
name String

影像图层的名称。

destroy Boolean true 可选

是否销毁,返回值为flag,表示是否移除成功。