StoryMapJS API
    Preparing search index...

    Interface OlLayer<SourceType, RendererType, Properties>

    Base class from which all layer types are derived. This should only be instantiated in the case where a custom layer is added to the map with a custom render function. Such a function can be specified in the options object, and is expected to return an HTML element.

    A visual representation of raster or vector map data. Layers group together those properties that pertain to how the data is to be displayed, irrespective of the source of that data.

    Layers are usually added to a map with [map.addLayer()]import("../Map.js").default#addLayer. Components like :ol/interaction/Draw~Draw use unmanaged layers internally. These unmanaged layers are associated with the map using [layer.setMap()]:ol/layer/Layer~Layer#setMap instead.

    A generic change event is fired when the state of the source changes. A sourceready event is fired when the layer's source is ready.

    import("../render/Event.js").RenderEvent#prerender

    import("../render/Event.js").RenderEvent#postrender

    import("../events/Event.js").BaseEvent#sourceready

    interface OlLayer<
        SourceType extends OlSource = OlSource,
        RendererType extends default = default,
        Properties extends { [x: string]: any } = { [x: string]: any },
    > {
        disposed: boolean;
        on: LayerOnSignature<EventsKey>;
        once: LayerOnSignature<EventsKey>;
        rendered: boolean;
        un: LayerOnSignature<void>;
        addChangeListener(key: string, listener: Listener): void;
        addEventListener(type: string, listener: Listener): void;
        applyProperties(source: BaseObject): void;
        changed(): void;
        clearRenderer(): void;
        createRenderer(): RendererType;
        dispatchEvent(event: string | BaseEvent): boolean | undefined;
        dispose(): void;
        disposeInternal(): void;
        get(key: string): any;
        getAttributions(view?: OlView | ViewStateLayerStateExtent): string[];
        getBackground(): false | BackgroundColor;
        getClassName(): string;
        getData(
            pixel: Pixel,
        ):
            | Uint8ClampedArray<ArrayBufferLike>
            | Uint8Array<ArrayBufferLike>
            | Float32Array<ArrayBufferLike>
            | DataView<ArrayBufferLike>
            | null;
        getDeclutter(): string;
        getExtent(): Extent | undefined;
        getFeatures(pixel: Pixel): Promise<FeatureLike[]>;
        getKeys(): string[];
        getLayersArray(
            array?: OlLayer<OlSource, LayerRenderer<any>, { [x: string]: any }>[],
        ): OlLayer<OlSource, LayerRenderer<any>, { [x: string]: any }>[];
        getLayerState(managed?: boolean): State;
        getLayerStatesArray(states?: State[]): State[];
        getListeners(type: string): Listener[] | undefined;
        getMapInternal(): OlMap | null;
        getMaxResolution(): number;
        getMaxZoom(): number;
        getMinResolution(): number;
        getMinZoom(): number;
        getOpacity(): number;
        getProperties(): NoInfer<NoInfer<Properties> & { [x: string]: any }>;
        getPropertiesInternal(): | Partial<
            NoInfer<NoInfer<Properties> & { [x: string]: any }>,
        >
        | null;
        getRenderer(): RendererType | null;
        getRenderSource(): SourceType | null;
        getRevision(): number;
        getSource(): SourceType | null;
        getSourceState(): State;
        getVisible(): boolean;
        getZIndex(): number | undefined;
        hasListener(type?: string): boolean;
        hasProperties(): boolean;
        hasRenderer(): boolean;
        isVisible(view?: OlView | ViewStateLayerStateExtent): boolean;
        notify(key: string, oldValue: any): void;
        onceInternal(
            type: string | string[],
            listener: (arg0: Event | BaseEvent) => unknown,
        ): EventsKey | EventsKey[];
        onInternal(
            type: string | string[],
            listener: (arg0: Event | BaseEvent) => unknown,
        ): EventsKey | EventsKey[];
        removeChangeListener(key: string, listener: Listener): void;
        removeEventListener(type: string, listener: Listener): void;
        render(
            frameState: FrameState | null,
            target: HTMLElement,
        ): HTMLElement | null;
        renderDeclutter(frameState: FrameState, layerState: State): void;
        renderDeferred(frameState: FrameState): void;
        set(key: string, value: any, silent?: boolean): void;
        setBackground(background?: BackgroundColor): void;
        setExtent(extent: Extent | undefined): void;
        setMap(map: OlMap | null): void;
        setMapInternal(map: OlMap | null): void;
        setMaxResolution(maxResolution: number): void;
        setMaxZoom(maxZoom: number): void;
        setMinResolution(minResolution: number): void;
        setMinZoom(minZoom: number): void;
        setOpacity(opacity: number): void;
        setProperties(values: Partial<NoInfer<Properties>>, silent?: boolean): void;
        setSource(source: SourceType | null): void;
        setVisible(visible: boolean): void;
        setZIndex(zindex: number): void;
        unInternal(
            type: string | string[],
            listener: (arg0: Event | BaseEvent) => unknown,
        ): void;
        unrender(): void;
        unset(key: string, silent?: boolean): void;
    }

    Type Parameters

    • SourceType extends OlSource = OlSource
    • RendererType extends default = default
    • Properties extends { [x: string]: any } = { [x: string]: any }

    Hierarchy

    Index
    disposed: boolean

    The object has already been disposed.

    on: LayerOnSignature<EventsKey>
    once: LayerOnSignature<EventsKey>
    rendered: boolean
    un: LayerOnSignature<void>
    • Parameters

      • key: string

        Key name.

      • listener: Listener

        Listener.

      Returns void

    • Parameters

      • type: string

        Type.

      • listener: Listener

        Listener.

      Returns void

    • Protected

      Apply any properties from another object without triggering events.

      Parameters

      • source: BaseObject

        The source object.

      Returns void

    • Increases the revision counter and dispatches a 'change' event.

      Returns void

    • This will clear the renderer so that a new one can be created next time it is needed

      Returns void

    • Protected

      Create a renderer for this layer.

      Returns RendererType

      A layer renderer.

    • Dispatches an event and calls all listeners listening for events of this type. The event parameter can either be a string or an Object with a type property.

      Parameters

      • event: string | BaseEvent

        Event object.

      Returns boolean | undefined

      false if anyone called preventDefault on the event object or if any of the listeners returned false.

    • Clean up.

      Returns void

    • Protected

      Extension point for disposable objects.

      Returns void

    • Gets a value.

      Parameters

      • key: string

        Key name.

      Returns any

      Value.

    • Get the attributions of the source of this layer for the given view.

      Parameters

      • Optionalview: OlView | ViewStateLayerStateExtent

        View or import("../Map.js").FrameState. Only required when the layer is not added to a map.

      Returns string[]

      Attributions for this layer at the given view.

    • Get the background for this layer.

      Returns false | BackgroundColor

      Layer background.

    • Returns string

      CSS class name.

    • Parameters

      • pixel: Pixel

        Pixel.

      Returns
          | Uint8ClampedArray<ArrayBufferLike>
          | Uint8Array<ArrayBufferLike>
          | Float32Array<ArrayBufferLike>
          | DataView<ArrayBufferLike>
          | null

      Pixel data.

    • Returns string

      Declutter

    • Return the :ol/extent~Extent extent of the layer or undefined if it will be visible regardless of extent.

      Returns Extent | undefined

      The layer extent.

    • Parameters

      • pixel: Pixel

        Pixel.

      Returns Promise<FeatureLike[]>

      Promise that resolves with an array of features.

    • Get a list of object property names.

      Returns string[]

      List of property names.

    • Parameters

      • Optionalarray: OlLayer<OlSource, LayerRenderer<any>, { [x: string]: any }>[]

        Array of layers (to be modified in place).

      Returns OlLayer<OlSource, LayerRenderer<any>, { [x: string]: any }>[]

      Array of layers.

    • This method is not meant to be called by layers or layer renderers because the state is incorrect if the layer is included in a layer group.

      Parameters

      • Optionalmanaged: boolean

        Layer is managed.

      Returns State

      Layer state.

    • Parameters

      • Optionalstates: State[]

        Optional list of layer states (to be modified in place).

      Returns State[]

      List of layer states.

    • Get the listeners for a specified event type. Listeners are returned in the order that they will be called in.

      Parameters

      • type: string

        Type.

      Returns Listener[] | undefined

      Listeners.

    • For use inside the library only.

      Returns OlMap | null

      Map.

    • Return the maximum resolution of the layer. Returns Infinity if the layer has no maximum resolution set.

      Returns number

      The maximum resolution of the layer.

    • Return the maximum zoom level of the layer. Returns Infinity if the layer has no maximum zoom set.

      Returns number

      The maximum zoom level of the layer.

    • Return the minimum resolution of the layer. Returns 0 if the layer has no minimum resolution set.

      Returns number

      The minimum resolution of the layer.

    • Return the minimum zoom level of the layer. Returns -Infinity if the layer has no minimum zoom set.

      Returns number

      The minimum zoom level of the layer.

    • Return the opacity of the layer (between 0 and 1).

      Returns number

      The opacity of the layer.

    • Get an object of all property names and values.

      Returns NoInfer<NoInfer<Properties> & { [x: string]: any }>

      Object.

    • Get an object of all property names and values.

      Returns Partial<NoInfer<NoInfer<Properties> & { [x: string]: any }>> | null

      Object.

    • Get the renderer for this layer.

      Returns RendererType | null

      The layer renderer.

    • Returns SourceType | null

      The source being rendered.

    • Get the version number for this object. Each time the object is modified, its version number will be incremented.

      Returns number

      Revision.

    • Get the layer source.

      Returns SourceType | null

      The layer source (or null if not yet set).

    • Returns State

      Source state.

    • Return the value of this layer's visible property. To find out whether the layer is visible on a map, use isVisible() instead.

      Returns boolean

      The value of the visible property of the layer.

    • Return the Z-index of the layer, which is used to order layers before rendering. Returns undefined if the layer is unmanaged.

      Returns number | undefined

      The Z-index of the layer.

    • Parameters

      • Optionaltype: string

        Type. If not provided, true will be returned if this event target has any listeners.

      Returns boolean

      Has listeners.

    • Returns boolean

      The object has properties.

    • Returns boolean

      The layer has a renderer.

    • The layer is visible on the map view, i.e. within its min/max resolution or zoom and extent, not set to visible: false, and not inside a layer group that is set to visible: false.

      Parameters

      • Optionalview: OlView | ViewStateLayerStateExtent

        View or import("../Map.js").FrameState. Only required when the layer is not added to a map.

      Returns boolean

      The layer is visible in the map view.

    • Parameters

      • key: string

        Key name.

      • oldValue: any

        Old value.

      Returns void

    • Protected

      Parameters

      • type: string | string[]

        Type.

      • listener: (arg0: Event | BaseEvent) => unknown

        Listener.

      Returns EventsKey | EventsKey[]

      Event key.

    • Protected

      Parameters

      • type: string | string[]

        Type.

      • listener: (arg0: Event | BaseEvent) => unknown

        Listener.

      Returns EventsKey | EventsKey[]

      Event key.

    • Parameters

      • key: string

        Key name.

      • listener: Listener

        Listener.

      Returns void

    • Parameters

      • type: string

        Type.

      • listener: Listener

        Listener.

      Returns void

    • In charge to manage the rendering of the layer. One layer type is bounded with one layer renderer.

      Parameters

      • frameState: FrameState | null

        Frame state.

      • target: HTMLElement

        Target which the renderer may (but need not) use for rendering its content.

      Returns HTMLElement | null

      The rendered element.

    • Parameters

      • frameState: FrameState

        Frame state.

      • layerState: State

        Layer state.

      Returns void

    • When the renderer follows a layout -> render approach, do the final rendering here.

      Parameters

      • frameState: FrameState

        Frame state

      Returns void

    • Sets a value.

      Parameters

      • key: string

        Key name.

      • value: any

        Value.

      • Optionalsilent: boolean

        Update without triggering an event.

      Returns void

    • Sets the background color.

      Parameters

      • Optionalbackground: BackgroundColor

        Background color.

      Returns void

    • Set the extent at which the layer is visible. If undefined, the layer will be visible at all extents.

      Parameters

      • extent: Extent | undefined

        The extent of the layer.

      Returns void

    • Sets the layer to be rendered on top of other layers on a map. The map will not manage this layer in its layers collection. This is useful for temporary layers. To remove an unmanaged layer from the map, use #setMap(null).

      To add the layer to a map and have it managed by the map, use :ol/Map~Map#addLayer instead.

      Parameters

      Returns void

    • For use inside the library only.

      Parameters

      Returns void

    • Set the maximum resolution at which the layer is visible.

      Parameters

      • maxResolution: number

        The maximum resolution of the layer.

      Returns void

    • Set the maximum zoom (exclusive) at which the layer is visible. Note that the zoom levels for layer visibility are based on the view zoom level, which may be different from a tile source zoom level.

      Parameters

      • maxZoom: number

        The maximum zoom of the layer.

      Returns void

    • Set the minimum resolution at which the layer is visible.

      Parameters

      • minResolution: number

        The minimum resolution of the layer.

      Returns void

    • Set the minimum zoom (inclusive) at which the layer is visible. Note that the zoom levels for layer visibility are based on the view zoom level, which may be different from a tile source zoom level.

      Parameters

      • minZoom: number

        The minimum zoom of the layer.

      Returns void

    • Set the opacity of the layer, allowed values range from 0 to 1.

      Parameters

      • opacity: number

        The opacity of the layer.

      Returns void

    • Sets a collection of key-value pairs. Note that this changes any existing properties and adds new ones (it does not remove any existing properties).

      Parameters

      • values: Partial<NoInfer<Properties>>

        Values.

      • Optionalsilent: boolean

        Update without triggering an event.

      Returns void

    • Set the layer source.

      Parameters

      Returns void

    • Set the visibility of the layer (true or false).

      Parameters

      • visible: boolean

        The visibility of the layer.

      Returns void

    • Set Z-index of the layer, which is used to order layers before rendering. The default Z-index is 0.

      Parameters

      • zindex: number

        The z-index of the layer.

      Returns void

    • Protected

      Unlisten for a certain type of event.

      Parameters

      • type: string | string[]

        Type.

      • listener: (arg0: Event | BaseEvent) => unknown

        Listener.

      Returns void

    • Called when a layer is not visible during a map render.

      Returns void

    • Unsets a property.

      Parameters

      • key: string

        Key name.

      • Optionalsilent: boolean

        Unset without triggering an event.

      Returns void