ImageryLayerCollection

new Cesium.ImageryLayerCollection()

Image layer collection class. This class is mainly used to manage image class layers.

Members

layerAdded : Event

This event is fired when a layer is added to the layer collection.
Default Value: Event()

layerMoved : Event

This event is triggered after a layer in the layer collection has moved.
Default Value: Event()

layerRemoved : Event

This event is fired when a layer is removed from the layer collection.
Default Value: Event()

layerShownOrHidden : Event

The layer visibility setting triggers this event when ImageryLayer#show changes.
Default Value: Event()

length : Number

Get the number of layers in the layer collection.

Methods

add(layer, index)

Add a layer to the layer collection.
Name Type Description
layer ImageryLayer The layer to be added.
index Number optional The index of the layer to be added.
Throws:
  • DeveloperError : The index value should be greater than or equal to 0 and less than the total number of layers.

addImageryProvider(imageryProvider, index)ImageryLayer

Add a layer to a layer collection by creating a new layer by the given image service provider.
Name Type Description
imageryProvider ImageryProvider The specified image service provider.
index Number optional The index of the layer to be added.
Returns:
The newly created image layer.
Example:
var imageryLayers = viewer.imageryLayers;
var labelImagery = new Cesium.WebMapTileServiceImageryProvider({
		url : 'http://[subdomain].tianditu.com/cia_w/wmts',
		layer : 'cia',
		style : 'default',
		format : 'tiles',
		tileMatrixSetID : 'w',
		credit : new Cesium.Credit('天地图全球影像中文注记服务'),
		subdomains : ['t0','t1','t2','t3','t4','t5','t6','t7']
	    });
        imageryLayers.addImageryProvider(labelImagery);.

contains(layer)Boolean

Determines if the specified layer is included in the layer collection.
Name Type Description
layer ImageryLayer The layer to be checked.
Returns:
The layer contained in the collection returns true, otherwise it returns false.

destroy()undefined

Frees the WebGL resources occupied by all layers in the collection. Once the resource occupied by the object is released, the object will not be used. Calling any command other than isDestroyed will throw an DeveloperError exception. Therefore, as shown in the example, the object allocates an undefined return value.
Returns:
Throws:
Example:
layerCollection = layerCollection && layerCollection.destroy();
See:

get(index)ImageryLayer

Gets the image layer object for the specified index in the layer collection.
Name Type Description
index Number Index value.
Returns:
Image layer object.

indexOf(layer)Number

Gets the index value of the specified layer in the layer collection.
Name Type Description
layer ImageryLayer The specified layer.
Returns:
The layer index value, or -1 if it does not exist.

isDestroyed()Boolean

Returns true if the object was released, otherwise returns false. Once the resource occupied by the object is released, the object will not be used. Calling any command other than isDestroyed will throw an DeveloperError exception.
Returns:
Returns true if the object was released, otherwise returns false.
See:

lower(layer)

Moves the specified layer in this layer set down one level.
Name Type Description
layer ImageryLayer The layer to be moved.
Throws:

lowerToBottom(layer)

Moves the specified layer in this layer set to the bottom.
Name Type Description
layer ImageryLayer The layer to be moved.
Throws:

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

Layer features are selected asynchronously by picking up the cursor. By citing ImageryProvider#pickFeatures, the pick cursor intersects the layer tile to find the intersecting layer features. Use Camera.getPickRay to calculate the pick cursor from the screen position.
Name Type Description
ray Ray Detect intersecting cursors.
scene Scene Scene object.
Returns:
A promise of a set of features is obtained by the intersection of the pick cursors. If you can quickly identify features that don't intersect (for example, unactivated layers support ImageryProvider#pickFeatures, or pick up cursors and layers Disjoint), the function returns undefined.
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);
        }
    });
}

raise(layer)

Moves the specified layer in this layer set up one level.
Name Type Description
layer ImageryLayer The layer to be moved.
Throws:

raiseToTop(layer)

Moves the specified layer in this layer set to the top.
Name Type Description
layer ImageryLayer The layer to be moved.
Throws:

remove(layer, destroy)Boolean

Remove a layer from the collection.
Name Type Default Description
layer ImageryLayer The layer to be removed.
destroy Boolean true optional Whether to release resources when removing.
Returns:
Returns true if the removal succeeds, otherwise returns false.

removeAll(destroy)

Remove all layers from the layer collection.
Name Type Default Description
destroy Boolean true optional Whether to release resources when removing.