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()
-
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.
-
-
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);.
-
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. -
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:
-
DeveloperError : The object is released.
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. -
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. -
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. -
Moves the specified layer in this layer set down one level.
Name Type Description layer
ImageryLayer The layer to be moved. Throws:
-
DeveloperError : The layer does not exist in the layer collection.
-
DeveloperError : The object is released.
-
-
Moves the specified layer in this layer set to the bottom.
Name Type Description layer
ImageryLayer The layer to be moved. Throws:
-
DeveloperError : The layer does not exist in the layer collection.
-
DeveloperError : The object is released.
-
-
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. UseCamera.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 supportImageryProvider#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); } }); }
-
Moves the specified layer in this layer set up one level.
Name Type Description layer
ImageryLayer The layer to be moved. Throws:
-
DeveloperError : The layer does not exist in the layer collection.
-
DeveloperError : The object is released.
-
-
Moves the specified layer in this layer set to the top.
Name Type Description layer
ImageryLayer The layer to be moved. Throws:
-
DeveloperError : The layer does not exist in the layer collection.
-
DeveloperError : The 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:
Returns true if the removal succeeds, otherwise returns false. -
Remove all layers from the layer collection.
Name Type Default Description destroy
Boolean true
optional Whether to release resources when removing.