3D-City Model
    Preparing search index...

    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.

    Cesium Viewer instance.

    Unique identifier for this collection.

    Human-readable label (for UI/legend).

    Tags for grouping/filtering.

    The map of child Layer instances (key: Layer.id).

    Set true to show all child layers on construction.

    Is group removable?

    Parent collection, if nested.

    Imagery stacking index for the group (if any).

    Shader for this collection.

    Collection-level styling.

    Data/attribution credits.

    Callback run when collection is shown/hidden.

    const group = new LayerCollection(viewer, { name: "Admin Boundaries" });
    group.content.set(layer.id, layer);
    group.show = true; // Shows all layers in the group

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _clippingPolygons: any
    _customShader: CustomShader
    _dynamicScreenSpaceError: any
    _dynamicScreenSpaceErrorDensity: any
    _dynamicScreenSpaceErrorFactor: any
    _dynamicScreenSpaceErrorHeightFalloff: any
    _maximumScreenSpaceError: any
    _opaque: boolean
    _parent: null | Layer
    _show: boolean
    _style: any
    content: any

    Map of child layers.

    deletable: boolean

    Is the layer removable?

    id: string

    Unique ID for this layer.

    imageryIndex: null | number
    name: string

    Display/UI name.

    onShowChange: (arg0: boolean) => void
    originalShader: CustomShader
    originalTranslucencyMode: any
    resolved: boolean
    styleManager: any
    tags: string[]

    Layer grouping/filter tags.

    type: null | string

    Always Layer.LayerTypes.COLLECTION for group layers.

    url: string

    Configuration/source URL.

    viewer: any
    LayerTypes: {
        B3DM: string;
        BASELAYER: string;
        COLLECTION: string;
        FEATURE: string;
        GEOJSON: string;
        GEOJSON3D: string;
        GLTF: string;
        IMAGERY: string;
        MESH: string;
        PARTICLE_SYSTEM: string;
        POINTS: string;
        TERRAIN: string;
    } = ...

    Static enumeration of supported layer types (for easy type checking).

    Accessors

    • get boundingSphere(): undefined | BoundingSphere

      Returns the bounding sphere of the layer, for spatial queries and UI zoom-to-fit. The implementation is type-dependent:

      • For tile/mesh/point clouds: directly returns content.boundingSphere.
      • For (Geo)JSON: computes bounding sphere from all polygon and polyline points.
      • For imagery: computes from imagery rectangle.
      • For terrain/default: returns undefined.

      Returns undefined | BoundingSphere

      The bounding sphere, or undefined if not computable.

    • get clippingPolygons(): any

      Get or set clipping polygons for this layer (used in 3D terrain/model clipping). Setter will propagate to the underlying Cesium content.

      Returns any

    • set clippingPolygons(cpc: any): void

      Get or set clipping polygons for this layer (used in 3D terrain/model clipping). Setter will propagate to the underlying Cesium content.

      Parameters

      • cpc: any

      Returns void

    • set color(c: Color): void

      Set the global color for all grouped features (handled externally). For mesh types, this may be handled elsewhere.

      Parameters

      • c: Color

      Returns void

    • get customShader(): any

      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.

      Returns any

    • set customShader(cs: any): void

      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.

      Parameters

      • cs: any

        The shader to apply or null to disable.

      Returns void

    • get dynamicScreenSpaceErrorDensity(): any

      Returns any

    • set dynamicScreenSpaceErrorDensity(value: any): void

      Parameters

      • value: any

      Returns void

    • get dynamicScreenSpaceErrorHeightFalloff(): any

      Returns any

    • set dynamicScreenSpaceErrorHeightFalloff(value: any): void

      Parameters

      • value: any

      Returns void

    • get opaque(): boolean

      Whether this layer is currently set as opaque. Triggers shader/mode update when changed.

      Returns boolean

    • set opaque(value: boolean): void

      Whether this layer is currently set as opaque. Triggers shader/mode update when changed.

      Parameters

      • value: boolean

      Returns void

    • get parent(): null | Layer

      Returns null | Layer

      • Current parent assigned, or null.
    • set parent(p: null | Layer): void

      Sets or gets the parent collection/group layer (if present). Use to build hierarchies or nested layer collections.

      Parameters

      • p: null | Layer

        Parent layer to assign.

      Returns void

    • get show(): boolean

      Returns the current show/hide state for the collection (not necessarily the same as the state of every individual child).

      Returns boolean

    • set show(s: boolean): void

      Shows or hides all child layers at once. Triggers the onShowChange callback.

      Parameters

      • s: boolean

      Returns void

    • get style(): any

      Sets or retrieves styling for the layer (e.g. for GeoJSON/tiles/features). For mesh types, style setting is usually not allowed.

      Returns any

    • set style(s: any): void

      Sets or retrieves styling for the layer (e.g. for GeoJSON/tiles/features). For mesh types, style setting is usually not allowed.

      Parameters

      • s: any

        Style object.

      Returns void

    Methods

    • 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.

      Parameters

      • layer: Layer

        Layer to add.

      Returns void

      If not a valid Layer.

    • Recursively collects the content objects of all layers whose IDs match any in layerIds. Searches through nested collections as well.

      Parameters

      • layerIds: string[]

        Array of IDs to match.

      Returns any[]

      Array of matched content objects.

    • Returns content objects for all layers with matching name.

      Parameters

      • name: string

      Returns any[]

      Array of content.

    • Returns content objects for all layers matching any of the provided types. Accepts any number of type arguments.

      Parameters

      • ...args: any

      Returns any[]

      Merged array of contents across types.

    • Collect IDs of all layers that match a condition. Used for implementing "byType", "byTag", and similar batch queries.

      Parameters

      • condition: (arg0: Layer) => boolean

        Predicate for layer inclusion.

      Returns string[]

      Matching layer IDs.

    • Returns IDs of all layers matching a specific name.

      Parameters

      • name: string

        The name to check for equality.

      Returns string[]

      Matching IDs.

    • Returns IDs of all layers with any tag matching the given array.

      Parameters

      • tags: string[]

        List of tags to match.

      Returns string[]

      IDs of all matching layers.

    • Recursively finds and returns the Layer object for the first matching name.

      Parameters

      • name: string

      Returns undefined | Layer

    • Checks if a given object is a valid Layer: Must be truthy, have an 'id' property, and be an actual Layer instance.

      Parameters

      • layer: any

        The object to check.

      Returns boolean

      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).

      Returns void

    • 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.

      Parameters

      • layer: Layer

        The Layer instance to remove.

      Returns void

      If layer is falsy.

    • Removes a Layer from the collection by its ID.

      Parameters

      • id: string

        The Layer's ID.

      Returns void

    • Replace the content for a given ID with a new Layer/content.

      Parameters

      • id: string

        The content (Layer) ID to replace.

      • newContent: Layer

        The new content (Layer) object.

      Returns boolean

      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.

      Parameters

      • show: boolean
      • excludeIds: string[]

      Returns void

    • Shows/hides this collection if its own ID is included in layerIds, then propagates to all contained layers.

      Parameters

      • show: boolean
      • layerIds: string[]

      Returns void