ImageryLayerCollection

new SuperMap3D.ImageryLayerCollection()

The image layer collection class is used to manage image layers.

Members

layerAdded : Event

The event is triggered after a layer is added to the layer collection.
Default Value: Event()

layerMoved : Event

The event is triggered afrer a layer in the layer collection has been moved.
Default Value: Event()

layerRemoved : Event

The event is triggered after a layer in the layer collection has been removed.
Default Value: Event()

layerShownOrHidden : Event

The event is triggered when the 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.

addGridProvider(gridProvider, index)GridLayer

Add a Grid tile service provider.
Name Type Description
gridProvider String Creat a new layer using the given raster layer provider, and add it to the layer collection.
index Number optional The index of the layer to be added. If the parameter is ignored, the new layer will be placed on top of all existing layers.
Returns:
The newly added layer.

addImageryProvider(imageryProvider, index)ImageryLayer

Creat a new layer using the given image service provider and add it to the layer collection.
Name Type Description
imageryProvider ImageryProvider The given image service provider.
index Number optional The index of the layer to be added.
Returns:
The newly added iamge layer.
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('Tianditu Global Imagery Chinese Annotation Service'),
		subdomains : ['t0','t1','t2','t3','t4','t5','t6','t7']
	    });
        imageryLayers.addImageryProvider(labelImagery);.

contains(layer)Boolean

Determine whether the layer collection contains the specified layer.
Name Type Description
layer ImageryLayer The layer to be checked.
Returns:
Return true if the layer collection layer contains the specified layer, otherwise ruturn false.

destroy()undefined

Release all the WebGL resources occupied by the layers in the collection. Once the resources occupied by the object are released, the object will no longer be usable, and calling any command other than isDestroyed will throw a DeveloperError exception. Therefore, as shown in the example, the object is assigned an undefined return value.
Returns:
Return undefined。
Throws:
Example:
layerCollection = layerCollection && layerCollection.destroy();
See:

get(index)ImageryLayer

Get the imagery layer object at the specified index in the layer collection.
Name Type Description
index Number The index value.
Returns:
The imagery layer object.

getImageryLayerByName(name)ImageryLayer

Get the corresponding image layer in the layer collection based on the layer name.
Name Type Description
name String The imagery layer name.
Returns:

indexOf(layer)Number

Get the index value of the specified layer in the layer collection.
Name Type Description
layer ImageryLayer The specified layer.
Returns:
The layer index value, return -1 if it doesn't exist.

isDestroyed()Boolean

Return true if the object has been released, otherwise return false. Once the resources occupied by the object are released, the object will no longer be usable, and calling any command other than isDestroyed will throw a DeveloperError exception.
Returns:
Return true if the object has been released, otherwise return false.
See:

lower(layer)

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

lowerToBottom(layer)

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

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

Asynchronously select layer features by picking with the cursor.By invoking ImageryProvider#pickFeatures, pick the cursor intersecting with the layer tiles to discover the intersecting layer features. Use Camera.getPickRayto calculate the pick cursor from the screen position.
Name Type Description
ray Ray The cursor for detecting intersections.
scene Scene Scene object.
Returns:
Get the promise of a set of features by picking intersecting cursor. If it can quickly determine that there are no intersecting features (e.g., no active layers support ImageryProvider#pickFeatures, or the pick cursor does not intersect with the layer), the function returns undefined.
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)

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

raiseToTop(layer)

Move the specified layer to this layer collection to the top.
Name Type Description
layer ImageryLayer The layer to be moved.
Throws:

remove(layer, destroy)Boolean

Reomove the specified layer in the layer collection.
Name Type Default Description
layer ImageryLayer The layer to be removed.
destroy Boolean true optional Whether to release resources upon removal.
Returns:
Return true if the removal is successful, otherwise return false.

removeAll(destroy)

Remove all layers in the layer collection.
Name Type Default Description
destroy Boolean true optional Whether to release resources upon removal.

removeImageryLayerById(id, destroy)

Remove the corresponding imagery layer from the layer collection based on the layer ID.
Name Type Default Description
id String The image layer ID.
destroy Boolean true optional Whether the removal was successful, with a return value as a flag.

removeImageryLayerByName(name, destroy)

Remove the corresponding image layer from the layer collection based on the layer name.
Name Type Default Description
name String The image layer name.
destroy Boolean true optional Whether the removal was successful, with a return value as a flag.