Class MVTLayer

MVTLayer

The MVTLayer is an OpenLayers layer that loads tile data from hiking, hiking proposition, hiking activity, points of interest or detours.

Before using the MVTLayer, you need to set the environment and the jwt token environment if needed.

Adding all the hiking of the user to the map:

// Create a mvt layer for hiking
const layer = new sww.MVTLayer({
layer: "hiking"
});

// Add it to the map
map.addLayer(layer);

For the other layers, you can use the same way only changing the layer name:

  • Hiking proposition: hiking_proposition
  • Hiking activity: hiking_activity
  • Points of interest: poi
  • Detours: detours

For hiking data, it uses a JWT token to load only user's specific data. For the other layers, no token is needed. No special scope is needed for the token, only the sub value is used to load the user's data.

For the hiking proposition and activity , the data can be filtered by organisation or uuids by passing the corresponding option:

// Create a mvt layer for hiking
const layer = new sww.MVTLayer({
layer: "hiking_activity",
organisation: "Jura Rando",
uuids: "uuid1, uuid2"
});

The uuids option is a string of uuids separated by a commas. Without the organisation option, the layer will display all the data.

For the poi layer, the data can be filtered by type by passing the 'poi_types' option:

// Create a mvt layer for hiking
const layer = new sww.MVTLayer({
layer: "poi",
poi_types: "type1, type2"
});

The poi_types option is a string of types separated by a commas.

Hierarchy

  • VectorTileLayer<RenderFeature>
    • MVTLayer

Constructors

  • Parameters

    • options: MVTLayerOptions

    Returns MVTLayer

Properties

disposed: boolean

The object has already been disposed.

on: VectorTileLayerOnSignature<EventsKey>
once: VectorTileLayerOnSignature<EventsKey>
rendered: boolean
un: VectorTileLayerOnSignature<void>

Methods

  • 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

  • Protected

    Create a renderer for this layer.

    Returns CanvasVectorTileLayerRenderer

    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 undefined | boolean

    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: View | 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
        | null
        | Uint8ClampedArray
        | Uint8Array
        | Float32Array
        | DataView

    Pixel data.

  • Returns string

    Declutter

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

    Returns undefined | Extent

    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: Layer<Source, LayerRenderer<any>>[]

      Array of layers (to be modified in place).

    Returns Layer<Source, LayerRenderer<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 undefined | Listener[]

    Listeners.

  • For use inside the library only.

    Returns null | Map

    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.

  • Return the level as number to which we will preload tiles up to.

    Returns number

    The level to preload tiles up to.

  • Get an object of all property names and values.

    Returns {
        [x: string]: any;
    }

    Object.

    • [x: string]: any
  • Get an object of all property names and values.

    Returns null | {
        [x: string]: any;
    }

    Object.

  • Returns undefined | number

    Render buffer.

  • Get the renderer for this layer.

    Returns null | CanvasVectorTileLayerRenderer

    The layer renderer.

  • Returns VectorTileRenderType

    The render mode.

  • Returns ((arg0: Feature<Geometry>, arg1: Feature<Geometry>) => undefined | null | number)

    Render order.

      • (arg0, arg1): undefined | null | number
      • Parameters

        • arg0: Feature<Geometry>
        • arg1: Feature<Geometry>

        Returns undefined | null | number

  • Returns null | VectorTile<RenderFeature>

    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 null | VectorTile<RenderFeature>

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

  • Returns State

    Source state.

  • Get the style for features. This returns whatever was passed to the style option at construction or to the setStyle method.

    Returns
        | undefined
        | null
        | StyleLike
        | FlatStyleLike

    Layer style.

  • Get the style function.

    Returns undefined | StyleFunction

    Layer style function.

  • Returns boolean

    Whether the rendered layer should be updated while animating.

  • Returns boolean

    Whether the rendered layer should be updated while interacting.

  • Whether we use interim tiles on error.

    Returns boolean

    Use interim tiles on error.

  • 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 undefined | number

    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: View | 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.

        • (arg0): unknown
        • Parameters

          • arg0: Event | BaseEvent

          Returns unknown

    Returns EventsKey | EventsKey[]

    Event key.

  • Protected

    Parameters

    • type: string | string[]

      Type.

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

      Listener.

        • (arg0): unknown
        • Parameters

          • arg0: Event | BaseEvent

          Returns unknown

    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: null | FrameState

      Frame state.

    • target: HTMLElement

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

    Returns null | HTMLElement

    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: undefined | Extent

      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 module:ol/Map~Map#addLayer instead.

    Parameters

    • map: null | Map

      Map.

    Returns void

  • For use inside the library only.

    Parameters

    • map: null | Map

      Map.

    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

  • Set the level as number to which we will preload tiles up to.

    Parameters

    • preload: number

      The level to preload tiles up to.

    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: {
          [x: string]: any;
      }

      Values.

      • [x: string]: any
    • Optionalsilent: boolean

      Update without triggering an event.

    Returns void

  • Parameters

    • renderOrder: undefined | null | OrderFunction

      Render order.

    Returns void

  • Set the layer source.

    Parameters

    • source: null | VectorTile<RenderFeature>

      The layer source.

    Returns void

  • Set the style for features. This can be a single style object, an array of styles, or a function that takes a feature and resolution and returns an array of styles. If set to null, the layer has no style (a null style), so only features that have their own styles will be rendered in the layer. Call setStyle() without arguments to reset to the default style. See [the ol/style/Style module]module:ol/style/Style~Style for information on the default style.

    If your layer has a static style, you can use [flat style]module:ol/style/flat~FlatStyle object literals instead of using the Style and symbolizer constructors (Fill, Stroke, etc.):

    vectorLayer.setStyle({
    "fill-color": "yellow",
    "stroke-color": "black",
    "stroke-width": 4
    })

    Parameters

    • Optionalstyle: null | StyleLike | FlatStyleLike

      Layer style.

    Returns void

  • Set whether we use interim tiles on error.

    Parameters

    • useInterimTilesOnError: boolean

      Use interim tiles on error.

    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.

        • (arg0): unknown
        • Parameters

          • arg0: Event | BaseEvent

          Returns unknown

    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