Construct a new LayerCollection.
Optional
options: object = {}Map of child layers.
Is the layer removable?
Unique ID for this layer.
Display/UI name.
Layer grouping/filter tags.
Always Layer.LayerTypes.COLLECTION for group layers.
Configuration/source URL.
Static
LayerStatic enumeration of supported layer types (for easy type checking).
Returns the bounding sphere of the layer, for spatial queries and UI zoom-to-fit. The implementation is type-dependent:
The bounding sphere, or undefined if not computable.
Get or set clipping polygons for this layer (used in 3D terrain/model clipping). Setter will propagate to the underlying Cesium content.
Get or set clipping polygons for this layer (used in 3D terrain/model clipping). Setter will propagate to the underlying Cesium content.
Set the global color for all grouped features (handled externally). For mesh types, this may be handled elsewhere.
Assigns a new custom shader to this layer (or disables if falsy). For non-GEOJSON layer types, handles full reconstruction (with translucency mode handling). For GEOJSON and GEOJSON3D, directly updates polygon or polyline material alpha.
Set the custom shader for the entire collection and all child layers. If the collection is opaque but no shader is passed, assigns a default opaque shader. If a shader is provided, adjusts its translucency mode based on opacity. Updates .customShader on each child layer.
The shader to apply or null to disable.
Whether this layer is currently set as opaque. Triggers shader/mode update when changed.
Whether this layer is currently set as opaque. Triggers shader/mode update when changed.
Returns the current show/hide state for the collection (not necessarily the same as the state of every individual child).
Shows or hides all child layers at once. Triggers the onShowChange callback.
Sets or retrieves styling for the layer (e.g. for GeoJSON/tiles/features). For mesh types, style setting is usually not allowed.
Sets or retrieves styling for the layer (e.g. for GeoJSON/tiles/features). For mesh types, style setting is usually not allowed.
Style object.
Enables for-of and iteration over all contained Layer objects.
Add a Layer as content to this collection. The new Layer is registered by its ID and this collection is set as its parent. Throws if the layer is invalid.
Layer to add.
Execute a function for each contained child layer.
Recursively collects the content objects of all layers whose IDs match any in layerIds. Searches through nested collections as well.
Array of IDs to match.
Array of matched content objects.
Returns content objects for all layers with matching name.
Array of content.
Returns content of all layers matching any tag in the list.
Array of content objects.
Returns content objects of all layers matching a given type.
Array of matching content objects.
Returns content objects for all layers matching any of the provided types. Accepts any number of type arguments.
Merged array of contents across types.
Collect IDs of all layers that match a condition. Used for implementing "byType", "byTag", and similar batch queries.
Predicate for layer inclusion.
Matching layer IDs.
Returns IDs of all layers matching a specific name.
The name to check for equality.
Matching IDs.
Returns IDs of all layers with any tag matching the given array.
List of tags to match.
IDs of all matching layers.
Returns IDs of all contained layers matching a given type.
IDs
Recursively searches and returns the Layer object matching a given ID.
Matching Layer, else undefined.
Recursively finds and returns the Layer object for the first matching name.
Collects all Layer objects in this collection (and nested collections) matching any ID in layerIds.
A new LayerCollection of the matched layers.
Returns LayerCollection of all layers matching any of the provided tags.
Tags to query.
Returns a LayerCollection containing all layers of a given type.
Checks if a given object is a valid Layer: Must be truthy, have an 'id' property, and be an actual Layer instance.
The object to check.
True if the object is a valid Layer instance.
Reapplies internal show states for all child layers (forces a re-propagation of their current visibility).
Removes all child layer content (calls removeContent on all descendants).
Removes a Layer from this collection, deletes it from the parent's content map and severs parent link. Also calls removeContent to clean up scene resources. Throws an error if undefined.
The Layer instance to remove.
Removes a Layer from the collection by its ID.
The Layer's ID.
Replace the content for a given ID with a new Layer/content.
The content (Layer) ID to replace.
The new content (Layer) object.
True if replaced, false if no matching ID.
Shows/hides all contained layers except those whose IDs are in excludeIds. Throws an error if excludeIds is not an array.
Shows/hides this collection if its own ID is included in layerIds, then propagates to all contained layers.
LayerCollection – Represents a group of layers managed as a unified collection.
Extends Layer but its content is a Map of Layer instances, and it propagates visibility and configuration changes to all members. Useful for batch operations, toggle groups, and organizational logic in Cesium or similar geospatial apps.
Param: viewer
Cesium Viewer instance.
Param: options
Param: options.id
Unique identifier for this collection.
Param: options.name
Human-readable label (for UI/legend).
Param: options.tags
Tags for grouping/filtering.
Param: options.content
The map of child Layer instances (key: Layer.id).
Param: options.show
Set true to show all child layers on construction.
Param: options.deletable
Is group removable?
Param: options.parent
Parent collection, if nested.
Param: options.imageryIndex
Imagery stacking index for the group (if any).
Param: options.customShader
Shader for this collection.
Param: options.style
Collection-level styling.
Param: options.credits
Data/attribution credits.
Param: options.maximumScreenSpaceError
Param: options.dynamicScreenSpaceError
Param: options.dynamicScreenSpaceErrorDensity
Param: options.dynamicScreenSpaceErrorFactor
Param: options.dynamicScreenSpaceErrorHeightFalloff
Param: options.onShowChange
Callback run when collection is shown/hidden.
Example