Interface Source
attribution?: string;
calculateTileZoom?: CalculateTileZoomFunction;
id: string;
isTileClipped?: boolean;
maxzoom: number;
minzoom: number;
reparseOverscaled?: boolean;
roundZoom?: boolean;
tileID?: CanonicalTileID;
tileSize: number;
type: string;
vectorLayerIds?: string[];
abortTile?(tile: Tile): Promise<void>;
fire(event: Event): unknown;
hasTile?(tileID: OverscaledTileID): boolean;
hasTransition(): boolean;
loaded(): boolean;
loadTile(tile: Tile): Promise<void | LoadTileResult>;
onAdd?(map: MapLibreMap): void;
onRemove?(map: MapLibreMap): void;
prepare?(): void;
serialize(): any;
shouldReloadTile?(
tile: Tile,
options: GeoJSONSourceShouldReloadTileOptions,
): boolean;
unloadTile?(tile: Tile): Promise<void>;
}
Implemented by
Properties
Optionalattribution
The attribution for the source.
OptionalcalculateTileZoom
Optional function to redefine how tiles are loaded at high pitch angles.
id
The id for the source. Must not be used by any existing source.
OptionalisTileClipped
false if tiles can be drawn outside their boundaries, true if they cannot.
maxzoom
The maximum zoom level for the source.
minzoom
The minimum zoom level for the source.
OptionalreparseOverscaled
true if tiles should be sent back to the worker for each overzoomed zoom level, false if not.
OptionalroundZoom
true if zoom levels are rounded to the nearest integer in the source data, false if they are floor-ed to the nearest integer.
OptionaltileID
tileSize
The tile size for the source.
Readonlytype
OptionalvectorLayerIds
Methods
OptionalabortTile
fire
OptionalhasTile
True is the tile is part of the source, false otherwise.
Parameters
- tileID: OverscaledTileID
The tile ID
Returns boolean
- tileID: OverscaledTileID
hasTransition
True if the source has transition, false otherwise.
Returns boolean
loaded
True if the source is loaded, false otherwise.
Returns boolean
loadTile
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
The tile to load
Returns Promise<void | LoadTileResult>
- tile: Tile
OptionalonAdd
This method is called when the source is added to the map.
Parameters
- map: MapLibreMap
The map instance
Returns void
- map: MapLibreMap
OptionalonRemove
This method is called when the source is removed from the map.
Parameters
- map: MapLibreMap
The map instance
Returns void
- map: MapLibreMap
Optionalprepare
Allows to execute a prepare step before the source is used.
Returns void
serialize
Returns any
A plain (stringifiable) JS object representing the current state of the source. Creating a source using the returned object as the
optionsshould result in a Source that is equivalent to this one.
OptionalshouldReloadTile
Optional function to determine whether a tile should be reloaded, given a set of options associated with a
MapSourceDataChangedEvent.Parameters
- tile: Tile
- options: GeoJSONSourceShouldReloadTileOptions
Returns boolean
The
Sourceinterface must be implemented by each source type, including "core" types (vector,raster,video, etc.) and all custom, third-party types.Event
data- Fired with{dataType: 'source', sourceDataType: 'metadata'}to indicate that any necessary metadata has been loaded so that it's okay to callloadTile; and with{dataType: 'source', sourceDataType: 'content'}to indicate that the source data has changed, so that any current caches should be flushed.