Class VectorTileSource

A Vector Tile source. Uses OpenLayers styles.

Example

const apiKey = 'my api key';
const vectorTileSource = new VectorTileSource({
url: `${'https://{a-d}.tiles.mapbox.com/v4/mapbox.mapbox-streets-v6/'
+ '{z}/{x}/{y}.vector.pbf?access_token='}${apiKey}`,
style: new Style(...), // Pass an OpenLayers style here
backgroundColor: 'hsl(47, 26%, 88%)',
});

Hierarchy

Constructors

Properties

_crs: string
_extent: Extent
_olUID: string = ...
_sourceProjection: Projection
_tileGrid: TileGrid
backgroundColor: string
containsFn: CustomContainsFn
datatype: TextureDataType

Gets the datatype of images generated by this source.

flipY: boolean

Gets whether images generated from this source should be flipped vertically.

isImageSource: boolean = true
isVectorTileSource: boolean = true
source: VectorTile
style: Style | StyleFunction
type: string
version: number

Methods

  • Adds a listener to an event type.

    Type Parameters

    • T extends "updated"

    Parameters

    Returns void

  • Type Parameters

    • T extends string

    Parameters

    Returns void

  • Returns an adjusted extent, width and height so that request pixels are aligned with source pixels, and requests do not oversample the source.

    Parameters

    • requestExtent: Extent

      The request extent.

    • requestWidth: number

      The width, in pixels, of the request extent.

    • requestHeight: number

      The height, in pixels, of the request extent.

    • margin: number = 0

      The margin, in pixels, around the initial extent.

    Returns {
        extent: Extent;
        height: number;
        width: number;
    }

    The adjusted parameters.

    • extent: Extent
    • height: number
    • width: number
  • Gets whether this source contains the specified extent. If a custom contains function is provided, it will be used. Otherwise, intersects() is used.

    This method is mainly used to discard non-relevant requests (i.e don't process regions that are not relevant to this source).

    Parameters

    • extent: Extent

      The extent to test.

    Returns boolean

  • Parameters

    • tile: VectorRenderTile

    Returns boolean

  • Fire an event type.

    Type Parameters

    • T extends "updated"

    Parameters

    Returns void

  • Disposes unmanaged resources of this source.

    Returns void

  • Returns the CRS of this source.

    Returns string

    The CRS.

  • Returns the extent of this source expressed in the CRS of the source.

    Returns Extent

    The extent of the source.

  • Gets the images for the specified extent and pixel size.

    Parameters

    Returns ImageResponse[]

    An array containing the functions to generate the images asynchronously.

  • Checks if listener is added to an event type.

    Type Parameters

    • T extends "updated"

    Parameters

    Returns boolean

  • Type Parameters

    • T extends string

    Parameters

    Returns boolean

  • Initializes the source.

    Parameters

    • options: {
          targetProjection: string;
      }

      Options.

      • targetProjection: string

        The target projection. Only useful for sources that are able to reproject their data on the fly (typically vector sources).

    Returns Promise<void>

    A promise that resolves when the source is initialized.

  • Test the intersection between the specified extent and this source's extent. This method may be overriden to perform special logic.

    Parameters

    • extent: Extent

      The extent to test.

    Returns boolean

    true if the extent and this source extent intersects, false otherwise.

  • Parameters

    • tile: VectorRenderTile

      The tile to load.

    Returns Promise<Texture>

    The promise containing the rasterized tile.

  • Loads all tiles in the specified extent and zoom level.

    Parameters

    • extent: Extent

      The tile extent.

    • zoom: number

      The zoom level.

    Returns ImageResponse[]

    The image requests.

  • Parameters

    • tile: VectorRenderTile

      The tile to render.

    Returns HTMLCanvasElement

    The canvas.

  • Parameters

    • tile: VectorRenderTile

    Returns CanvasTexture

  • Removes a listener from an event type.

    Type Parameters

    • T extends "updated"

    Parameters

    Returns void

  • Type Parameters

    • T extends string

    Parameters

    Returns void

  • Raises an event to reload the source.

    Returns void

Generated using TypeDoc