Imagery layer collection class. This class is mainly used to manage image layers.
Members
-
layerAdded : Event
-
This event is triggered 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 triggered when a layer is removed from the layer collection.
-
Default Value:
Event()
-
layerShownOrHidden : Event
-
This event is triggered when the layer visibility setting ImageryLayer#show changes.
-
Default Value:
Event()
-
Get the number of layers in the layer collection.
Methods
-
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 slice service provider.
Name Type Description gridProvider
String Create a new layer through the given raster layer provider and add it to the layer collection. index
Number optional The index of the layer to be added (if omitted, the new layer will be located above all existing layers). Returns:
Newly added layer. -
addImageryProvider(imageryProvider, index) → ImageryLayer
-
Create a new layer through a given image service provider and add it to the layer collection.
Name Type Description imageryProvider
ImageryProvider The designated image service provider. index
Number optional The index of the layer to be added. Returns:
The newly created imagery 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);.
-
Determine whether the specified layer is included in the layer set.
Name Type Description layer
ImageryLayer The layer to be checked. Returns:
Return true if the layer is included in the collection, otherwise false. -
Release the WebGL resources occupied by all layers in the collection. Once the resources occupied by the object are released, the object cannot be used. Calling any command other than isDestroyed will throw an
DeveloperError
exception. Therefore, as the example shows, the object is assigned an undefined return value.Returns:
Throws:
-
DeveloperError : Object is released.
Example:
layerCollection = layerCollection && layerCollection.destroy();
See:
-
-
get(index) → ImageryLayer
-
Get the imagery layer object of the specified index in the layer collection.
Name Type Description index
Number Index value. Returns:
Imagery layer object. -
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, or -1 if it does not exist. -
If the object is released, return true, otherwise return false. Once the resources occupied by the object are released, the object cannot be used. Calling any command other than isDestroyed will throw an
DeveloperError
exception.Returns:
If the object is released, return true, otherwise return false. -
Move the specified layer in this layer set to the next layer.
Name Type Description layer
ImageryLayer The layer to be moved. Throws:
-
DeveloperError : The layer does not exist in the layer set.
-
DeveloperError : Object is released.
-
-
Move the specified layer in this layer set to the bottom layer.
Name Type Description layer
ImageryLayer The layer to be moved. Throws:
-
DeveloperError : The layer does not exist in the layer set.
-
DeveloperError : Object is released.
-
-
pickImageryLayerFeatures(ray, scene) → Promise.<Array.<ImageryLayerFeatureInfo>>|undefined
-
Asynchronously select layer features with the pick cursor. By quoting
ImageryProvider#pickFeatures
, pick the cursor to intersect the layer tile, and find the intersecting layer feature. UseCamera.getPickRay
to calculate the pickup cursor from the screen position.Name Type Description ray
Ray Detect intersecting cursors. scene
Scene Scene object. Returns:
Obtain the promise of a set of features by picking the intersection of the cursor. If it can be quickly determined that there is no intersecting feature (for example, no active layer supportsImageryProvider#pickFeatures
, or the pick cursor does not intersect the layer), 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); } }); }
-
Move the specified layer in this layer set one layer up.
Name Type Description layer
ImageryLayer The layer to be moved. Throws:
-
DeveloperError : The layer does not exist in the layer set.
-
DeveloperError : Object is released.
-
-
Move the specified layer in this layer collection to the topmost layer.
Name Type Description layer
ImageryLayer The layer to be moved. Throws:
-
DeveloperError : The layer does not exist in the layer set.
-
DeveloperError : Object is released.
-
-
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:
Return true if the removal is successful, otherwise false. -
Remove all layers in the layer collection.
Name Type Default Description destroy
Boolean true
optional Whether to release resources when removing.