new ImageryLayerCollection()
Image layer collection class. This type is mainly used for managing image layers.
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
Get the number of layers in the layer collection.
Methods
-
add(layer, index)
-
Add a layer to the layer collection.
Name Type Description layerImageryLayer The layer to be added.
indexNumber optional The index of the layer to be added.
Throws:
-
The index value should be greater than or equal to 0 and less than the total number of layers.
- Type
- DeveloperError
-
-
addGridProvider(gridProvider, index){GridLayer}
-
Add a Grid tile service provider.
Name Type Description gridProviderString Create a new layer using the given grid layer provider and add it to the layer collection.
indexNumber optional The index of the layer to be added (if ignored, the newly added layer will be located above all existing layers).
Returns:
Type Description GridLayer Newly added layers. -
addImageryProvider(imageryProvider, index){ImageryLayer}
-
Create a new layer through the given image service provider and add it to the layer collection.
Name Type Description imageryProviderImageryProvider Designated image service provider.
indexNumber optional The index of the layer to be added.
Returns:
Type Description ImageryLayer Newly created image 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('天地图全球影像中文注记服务'), subdomains : ['t0','t1','t2','t3','t4','t5','t6','t7'] }); imageryLayers.addImageryProvider(labelImagery);. -
contains(layer){Boolean}
-
Determine whether the specified layer is included in the layer collection.
Name Type Description layerImageryLayer Layer to be checked.
Returns:
Type Description Boolean If the layer is included in the collection, return true; otherwise, return false. -
destroy(){undefined}
-
Release WebGL resources occupied by all layers in the collection. Once the resources occupied by the object are released, the object cannot be used, and calling any command other than isDestroyed will throw a Developers Error exception. Therefore, as shown in the example, the object is assigned an undefined return value.
Throws:
-
The object has been released.
- Type
- DeveloperError
Returns:
Type Description undefined Return undefined. Example
layerCollection = layerCollection && layerCollection.destroy(); -
-
get(index){ImageryLayer}
-
Retrieve image layer objects from the specified index in the layer collection.
Name Type Description indexNumber Index value.
Returns:
Type Description ImageryLayer Image layer object. -
indexOf(layer){Number}
-
Retrieve the index value of the specified layer in the layer collection.
Name Type Description layerImageryLayer The specified layer.
Returns:
Type Description Number If the layer index value does not exist, return -1. -
isDestroyed(){Boolean}
-
If the object is released, return true; otherwise, return false. Once the resources occupied by the object are released, the object cannot be used, and calling any command other than isDestroyed will throw a Developers Error exception.
Returns:
Type Description Boolean If the object is released, return true; otherwise, return false. -
lower(layer)
-
Move the specified layer in this layer collection down one layer.
Name Type Description layerImageryLayer The layer to be moved.
Throws:
-
-
The layer does not exist in the layer collection.
- Type
- DeveloperError
-
-
-
The object has been released.
- Type
- DeveloperError
-
-
-
lowerToBottom(layer)
-
Move the specified layer in this layer collection to the lowest level.
Name Type Description layerImageryLayer The layer to be moved.
Throws:
-
-
The layer does not exist in the layer collection.
- Type
- DeveloperError
-
-
-
The object has been released.
- Type
- DeveloperError
-
-
-
pickImageryLayerFeatures(ray, scene){Promise.<Array.<ImageryLayerFeatureInfo>>|undefined}
-
Asynchronous selection of layer features by picking the cursor. By citing ImageryProvider # pickFeatures, pick the cursor that intersects with the layer tile and discover the intersecting layer features. Use Camera.getPickRay to calculate the pick cursor from the screen position.
Name Type Description rayRay Detect intersecting cursor.
sceneScene Scene objects.
Returns:
Type Description Promise.<Array.<ImageryLayerFeatureInfo>> | undefined A promise to obtain a set of features by picking cursor intersections. If it is possible to quickly determine features that do not intersect (for example, if an inactive layer supports ImageryProvider # pickFeatures, or if 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 layer in this layer collection up one layer.
Name Type Description layerImageryLayer The layer to be moved.
Throws:
-
-
The layer does not exist in the layer collection.
- Type
- DeveloperError
-
-
-
The object has been released.
- Type
- DeveloperError
-
-
-
raiseToTop(layer)
-
Move the specified layer in this layer collection to the topmost level.
Name Type Description layerImageryLayer The layer to be moved.
Throws:
-
-
The layer does not exist in the layer collection.
- Type
- DeveloperError
-
-
-
The object has been released.
- Type
- DeveloperError
-
-
-
remove(layer, destroy){Boolean}
-
Remove a layer from the collection.
Name Type Default Description layerImageryLayer Layers to be removed.
destroyBoolean true optional Whether to release resources when removing.
Returns:
Type Description Boolean Return true for successful removal, otherwise return false. -
removeAll(destroy)
-
Remove all layers from the layer collection.
Name Type Default Description destroyBoolean true optional Whether to release resources when removing.
-
removeImageryLayerById(id, destroy)
-
Remove the corresponding image layer from the collection based on the layer ID.
Name Type Default Description idNumber The ID of the image layer.
destroyBoolean true optional Whether to destroy, the return value is flag, indicating whether the removal was successful.
-
removeImageryLayerByName(name, destroy)
-
Remove the corresponding image layer from the collection based on the layer name.
Name Type Default Description nameString The name of the image layer.
destroyBoolean true optional Whether to destroy, the return value is flag, indicating whether the removal was successful.