Skip to content

Interface: Source

The Source interface must be implemented by each source type, including "core" types (vector, raster, video, etc.) and all custom, third-party types.

data - Fired with {dataType: 'source', sourceDataType: 'metadata'} to indicate that any necessary metadata has been loaded so that it's okay to call loadTile; and with {dataType: 'source', sourceDataType: 'content'} to indicate that the source data has changed, so that any current caches should be flushed.

Implemented by

Methods

abortTile

abortTile(tile): Promise<void>

Allows to abort a tile loading.

Parameters

Name Type Description
tile Tile The tile to abort

Returns

Promise<void>

Defined in

src/source/source.ts:103


fire

fire(event): unknown

An ability to fire an event to all the listeners, see Evented

Parameters

Name Type Description
event Event The event to fire

Returns

unknown

Defined in

src/source/source.ts:77


hasTile

hasTile(tileID): boolean

True is the tile is part of the source, false otherwise.

Parameters

Name Type Description
tileID OverscaledTileID The tile ID

Returns

boolean

Defined in

src/source/source.ts:98


hasTransition

hasTransition(): boolean

True if the source has transiotion, false otherwise.

Returns

boolean

Defined in

src/source/source.ts:68


loadTile

loadTile(tile): Promise<void>

This method does the heavy lifting of loading a tile. In most cases it will defer the work to the relevant worker source.

Parameters

Name Type Description
tile Tile The tile to load

Returns

Promise<void>

Defined in

src/source/source.ts:93


loaded

loaded(): boolean

True if the source is loaded, false otherwise.

Returns

boolean

Defined in

src/source/source.ts:72


onAdd

onAdd(map): void

This method is called when the source is added to the map.

Parameters

Name Type Description
map Map The map instance

Returns

void

Defined in

src/source/source.ts:82


onRemove

onRemove(map): void

This method is called when the source is removed from the map.

Parameters

Name Type Description
map Map The map instance

Returns

void

Defined in

src/source/source.ts:87


prepare

prepare(): void

Allows to execute a prepare step before the source is used.

Returns

void

Defined in

src/source/source.ts:118


serialize

serialize(): any

Returns

any

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.

Defined in

src/source/source.ts:114


unloadTile

unloadTile(tile): Promise<void>

Allows to unload a tile.

Parameters

Name Type Description
tile Tile The tile to unload

Returns

Promise<void>

Defined in

src/source/source.ts:108

Properties

attribution

Optional attribution: string

The attribution for the source.

Defined in

src/source/source.ts:50


id

id: string

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

Defined in

src/source/source.ts:34


isTileClipped

Optional isTileClipped: boolean

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

Defined in

src/source/source.ts:58


maxzoom

maxzoom: number

The maximum zoom level for the source.

Defined in

src/source/source.ts:42


minzoom

minzoom: number

The minimum zoom level for the source.

Defined in

src/source/source.ts:38


reparseOverscaled

Optional reparseOverscaled: boolean

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

Defined in

src/source/source.ts:63


roundZoom

Optional roundZoom: boolean

true if zoom levels are rounded to the nearest integer in the source data, false if they are floor-ed to the nearest integer.

Defined in

src/source/source.ts:54


tileSize

tileSize: number

The tile size for the source.

Defined in

src/source/source.ts:46