---
title: "VectorTileSource | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Class VectorTileSource`Maptiler`

A source containing vector tiles in [Maplibre Vector Tile format](https://maplibre.org/maplibre-tile-spec/) or [Mapbox Vector Tile format](https://docs.mapbox.com/vector-tiles/reference/). (See the [Style Specification](https://maplibre.org/maplibre-style-spec/) for detailed documentation of options.)

#### Example[](#example)

```typescript
map.addSource('some id', {
    type: 'vector',
    url: 'https://demotiles.maplibre.org/tiles/tiles.json'
});
```

#### Example[](#example-1)

```typescript
map.addSource('some id', {
    type: 'vector',
    tiles: ['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt'],
    minzoom: 6,
    maxzoom: 14
});
```

#### Example[](#example-2)

```typescript
map.getSource('some id').setUrl("https://demotiles.maplibre.org/tiles/tiles.json");
```

#### Example[](#example-3)

```typescript
map.getSource('some id').setTiles(['https://d25uarhxywzl1j.cloudfront.net/v0.1/{z}/{x}/{y}.mvt']);
```

#### See[](#see)

[Add a vector tile source](https://maplibre.org/maplibre-gl-js/docs/examples/add-a-vector-tile-source/)

#### Hierarchy ([View Summary](https://docs.maptiler.com/sdk-js/api-reference/hierarchy/#VectorTileSource))

-   [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/)
    -   VectorTileSource

##### Index

### Constructors[](#constructors)

[constructor](#constructor)

### Properties[](#properties)

[bounds](#bounds) [dispatcher](#dispatcher) [encoding](#encoding) [id](#id) [isTileClipped](#istileclipped) [map](#map) [maxzoom](#maxzoom) [minzoom](#minzoom) [promoteId](#promoteid) [reparseOverscaled](#reparseoverscaled) [scheme](#scheme) [tileBounds](#tilebounds) [tiles](#tiles) [tileSize](#tilesize) [type](#type) [url](#url)

### Methods[](#methods)

[abortTile](#aborttile) [fire](#fire) [hasTile](#hastile) [hasTransition](#hastransition) [listens](#listens) [load](#load) [loaded](#loaded) [loadTile](#loadtile) [off](#off) [on](#on) [onAdd](#onadd) [once](#once) [onRemove](#onremove) [serialize](#serialize) [setEventedParent](#seteventedparent) [setSourceProperty](#setsourceproperty) [setTiles](#settiles) [setUrl](#seturl) [unloadTile](#unloadtile)

## Constructors[](#constructors-1)

### constructor[](#constructor)

-   new VectorTileSource(  
        id: string,  
        options: [VectorTileSourceOptions](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.VectorTileSourceOptions/),  
        dispatcher: [Dispatcher](https://docs.maptiler.com/sdk-js/api-reference/classes/Dispatcher/),  
        eventedParent: [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/),  
    ): VectorTileSource[](#constructorvectortilesource)
    
    #### Parameters
    
    -   id: string
    -   options: [VectorTileSourceOptions](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.VectorTileSourceOptions/)
    -   dispatcher: [Dispatcher](https://docs.maptiler.com/sdk-js/api-reference/classes/Dispatcher/)
    -   eventedParent: [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/)
    
    #### Returns VectorTileSource
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[constructor](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#constructor)
    

## Properties[](#properties-1)

### bounds[](#bounds)

bounds: \[number, number, number, number\]

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[bounds](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#bounds)

### dispatcher[](#dispatcher)

dispatcher: [Dispatcher](https://docs.maptiler.com/sdk-js/api-reference/classes/Dispatcher/)

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[dispatcher](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#dispatcher)

### encoding[](#encoding)

encoding: string

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[encoding](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#encoding)

### id[](#id)

id: string

The id for the source. Must not be used by any existing source.

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[id](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#id)

### isTileClipped[](#istileclipped)

isTileClipped: boolean

`false` if tiles can be drawn outside their boundaries, `true` if they cannot.

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[isTileClipped](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#istileclipped)

### map[](#map)

map: [MapLibreMap](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreMap/)

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[map](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#map)

### maxzoom[](#maxzoom)

maxzoom: number

The maximum zoom level for the source.

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[maxzoom](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#maxzoom)

### minzoom[](#minzoom)

minzoom: number

The minimum zoom level for the source.

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[minzoom](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#minzoom)

### promoteId[](#promoteid)

promoteId: [PromoteIdSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/PromoteIdSpecification/)

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[promoteId](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#promoteid)

### reparseOverscaled[](#reparseoverscaled)

reparseOverscaled: boolean

`true` if tiles should be sent back to the worker for each overzoomed zoom level, `false` if not.

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[reparseOverscaled](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#reparseoverscaled)

### scheme[](#scheme)

scheme: string

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[scheme](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#scheme)

### tileBounds[](#tilebounds)

tileBounds: [TileBounds](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.TileBounds/)

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[tileBounds](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#tilebounds)

### tiles[](#tiles)

tiles: string\[\]

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[tiles](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#tiles)

### tileSize[](#tilesize)

tileSize: number

The tile size for the source.

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[tileSize](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#tilesize)

### type[](#type)

type: "vector"

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[type](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#type)

### url[](#url)

url: string

Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[url](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#url)

## Methods[](#methods-1)

### abortTile[](#aborttile)

-   abortTile(tile: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/)): Promise<void\>[](#aborttile-1)
    
    Allows to abort a tile loading.
    
    #### Parameters
    
    -   tile: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/)
        
        The tile to abort
        
    
    #### Returns Promise<void\>
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[abortTile](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#aborttile)
    

### fire[](#fire)

-   fire(event: string | [Event](https://docs.maptiler.com/sdk-js/api-reference/classes/Event/), properties?: any): this[](#fire-1)
    
    An ability to fire an event to all the listeners, see [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/)
    
    #### Parameters
    
    -   event: string | [Event](https://docs.maptiler.com/sdk-js/api-reference/classes/Event/)
        
        The event to fire
        
    -   `Optional`properties: any
    
    #### Returns this
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[fire](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#fire)
    

### hasTile[](#hastile)

-   hasTile(tileID: [OverscaledTileID](https://docs.maptiler.com/sdk-js/api-reference/classes/OverscaledTileID/)): boolean[](#hastile-1)
    
    True is the tile is part of the source, false otherwise.
    
    #### Parameters
    
    -   tileID: [OverscaledTileID](https://docs.maptiler.com/sdk-js/api-reference/classes/OverscaledTileID/)
        
        The tile ID
        
    
    #### Returns boolean
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[hasTile](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#hastile)
    

### hasTransition[](#hastransition)

-   hasTransition(): boolean[](#hastransition-1)
    
    True if the source has transition, false otherwise.
    
    #### Returns boolean
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[hasTransition](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#hastransition)
    

### listens[](#listens)

-   listens(type: string): boolean[](#listens-1)
    
    Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
    
    #### Parameters
    
    -   type: string
        
        The event type
        
    
    #### Returns boolean
    
    `true` if there is at least one registered listener for specified event type, `false` otherwise
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[listens](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#listens)
    

### load[](#load)

-   load(sourceDataChanged?: boolean): Promise<void\>[](#load-1)
    
    #### Parameters
    
    -   `Optional`sourceDataChanged: boolean
    
    #### Returns Promise<void\>
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[load](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#load)
    

### loaded[](#loaded)

-   loaded(): boolean[](#loaded-1)
    
    True if the source is loaded, false otherwise.
    
    #### Returns boolean
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[loaded](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#loaded)
    

### loadTile[](#loadtile)

-   loadTile(tile: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/)): Promise<void | [LoadTileResult](https://docs.maptiler.com/sdk-js/api-reference/types/LoadTileResult/)\>[](#loadtile-1)
    
    This method does the heavy lifting of loading a tile. In most cases it will defer the work to the relevant worker source.
    
    #### Parameters
    
    -   tile: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/)
        
        The tile to load
        
    
    #### Returns Promise<void | [LoadTileResult](https://docs.maptiler.com/sdk-js/api-reference/types/LoadTileResult/)\>
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[loadTile](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#loadtile)
    

### off[](#off)

-   off(type: string, listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)): this[](#off-1)
    
    Removes a previously registered event listener.
    
    #### Parameters
    
    -   type: string
        
        The event type to remove listeners for.
        
    -   listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)
        
        The listener function to remove.
        
    
    #### Returns this
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[off](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#off)
    

### on[](#on)

-   on(type: string, listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)): [Subscription](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Subscription/)[](#on-1)
    
    Adds a listener to a specified event type.
    
    #### Parameters
    
    -   type: string
        
        The event type to add a listen for.
        
    -   listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)
        
        The function to be called when the event is fired. The listener function is called with the data object passed to `fire`, extended with `target` and `type` properties.
        
    
    #### Returns [Subscription](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Subscription/)
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[on](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#on)
    

### `Maptiler`onAdd[](#onadd)

-   onAdd(map: [MapLibreMap](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreMap/) | [Map](https://docs.maptiler.com/sdk-js/api-reference/classes/Map/)): void[](#onadd-1)
    
    This method is called when the source is added to the map.
    
    #### Parameters
    
    -   map: [MapLibreMap](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreMap/) | [Map](https://docs.maptiler.com/sdk-js/api-reference/classes/Map/)
        
        The map instance
        
    
    #### Returns void
    
    Overrides [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[onAdd](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#onadd)
    

### once[](#once)

-   once(type: string, listener?: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)): Promise<any\> | VectorTileSource[](#once-1)
    
    Adds a listener that will be called only once to a specified event type.
    
    The listener will be called first time the event fires after the listener is registered.
    
    #### Parameters
    
    -   type: string
        
        The event type to listen for.
        
    -   `Optional`listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)
        
        The function to be called when the event is fired the first time.
        
    
    #### Returns Promise<any\> | VectorTileSource
    
    `this` or a promise if a listener is not provided
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[once](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#once)
    

### onRemove[](#onremove)

-   onRemove(): void[](#onremove-1)
    
    This method is called when the source is removed from the map.
    
    #### Returns void
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[onRemove](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#onremove)
    

### serialize[](#serialize)

-   serialize(): [VectorSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/VectorSourceSpecification/)[](#serialize-1)
    
    #### Returns [VectorSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/VectorSourceSpecification/)
    
    A plain (stringifiable) JS object representing the current state of the source. Creating a source using the returned object as the `options` should result in a Source that is equivalent to this one.
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[serialize](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#serialize)
    

### setEventedParent[](#seteventedparent)

-   setEventedParent(parent?: [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/) | null, data?: any): this[](#seteventedparent-1)
    
    Bubble all events fired by this instance of Evented to this parent instance of Evented.
    
    #### Parameters
    
    -   `Optional`parent: [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/) | null
    -   `Optional`data: any
    
    #### Returns this
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[setEventedParent](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#seteventedparent)
    

### setSourceProperty[](#setsourceproperty)

-   setSourceProperty(callback: Function): void[](#setsourceproperty-1)
    
    #### Parameters
    
    -   callback: Function
    
    #### Returns void
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[setSourceProperty](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#setsourceproperty)
    

### setTiles[](#settiles)

-   setTiles(tiles: string\[\]): this[](#settiles-1)
    
    Sets the source `tiles` property and re-renders the map.
    
    #### Parameters
    
    -   tiles: string\[\]
        
        An array of one or more tile source URLs, as in the TileJSON spec.
        
    
    #### Returns this
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[setTiles](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#settiles)
    

### setUrl[](#seturl)

-   setUrl(url: string): this[](#seturl-1)
    
    Sets the source `url` property and re-renders the map.
    
    #### Parameters
    
    -   url: string
        
        A URL to a TileJSON resource. Supported protocols are `http:` and `https:`.
        
    
    #### Returns this
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[setUrl](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#seturl)
    

### unloadTile[](#unloadtile)

-   unloadTile(tile: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/)): Promise<void\>[](#unloadtile-1)
    
    Allows to unload a tile.
    
    #### Parameters
    
    -   tile: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/)
        
        The tile to unload
        
    
    #### Returns Promise<void\>
    
    Inherited from [VectorTileSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/).[unloadTile](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.VectorTileSource/#unloadtile)
