Class: VectorTile

ol/source/VectorTile~VectorTile


import VectorTile from 'ol/source/VectorTile';

Class for layer sources providing vector data divided into a tile grid, to be used with module:ol/layer/VectorTile~VectorTile. Although this source receives tiles with vector features from the server, it is not meant for feature editing. Features are optimized for rendering, their geometries are clipped at or near tile boundaries and simplified for a view resolution. See module:ol/source/Vector~VectorSource for vector sources that are suitable for feature editing.

new VectorTile(options)

source/VectorTile.js, line 74
Name Type Description
options

Vector tile options.

Name Type Default Description
attributions module:ol/source/Source~AttributionLike

Attributions.

cacheSize number 128

Cache size.

format module:ol/format/Feature~FeatureFormat

Feature format for tiles. Used and required by the default.

overlaps boolean true

This source may have overlapping geometries. Setting this to false (e.g. for sources with polygons that represent administrative boundaries or TopoJSON sources) allows the renderer to optimise fill and stroke operations.

projection module:ol/proj~ProjectionLike

Projection.

state module:ol/source/State

Source state.

tileClass module:ol/VectorTile~TileClass

Class used to instantiate image tiles. Default is module:ol/VectorTile.

maxZoom number 22

Optional max zoom level.

minZoom number

Optional min zoom level.

tileSize number | module:ol/size~Size 512

Optional tile size.

tileGrid module:ol/tilegrid/TileGrid~TileGrid

Tile grid.

tileLoadFunction module:ol/Tile~LoadFunction

Optional function to load a tile given a URL. Could look like this:

function(tile, url) {
  tile.setLoader(function() {
    var data = // ... fetch data
    var format = tile.getFormat();
    tile.setProjection(format.readProjection(data));
    tile.setFeatures(format.readFeatures(data, {
      // featureProjection is not required for ol/format/MVT
      featureProjection: map.getView().getProjection()
    }));
    // the line below is only required for ol/format/MVT
    tile.setExtent(format.getLastExtent());
  };
});
tileUrlFunction module:ol/Tile~UrlFunction

Optional function to get tile URL given a tile coordinate and the projection.

url string

URL template. Must include {x}, {y} or {-y}, and {z} placeholders. A {?-?} template pattern, for example subdomain{a-f}.domain.com, may be used instead of defining each one separately in the urls option.

transition number

A duration for tile opacity transitions in milliseconds. A duration of 0 disables the opacity transition.

urls Array.<string>

An array of URL templates.

wrapX boolean true

Whether to wrap the world horizontally. When set to false, only one world will be rendered. When set to true, tiles will be wrapped horizontally to render multiple worlds.

Fires:

Methods

clear()

source/VectorTile.js, line 153

clear module:ol/TileCache~TileCache and delete all source tiles