For AI agents: a documentation index is available at /llms.txt. Markdown versions of all pages are available by appending .md to any URL.
Class TilePreloaderMaptiler
Constructors
Maptilerconstructor
-
Parameters
- map: Map
Returns TilePreloader
Methods
MaptilerabortAll
-
Cancels all in-flight preload requests. Called automatically when a new camera movement begins so stale prefetches do not waste quota.
Returns void
MaptilerpreloadByTileIDs
-
Preloads a specific set of tiles by their IDs (
"z/x/y"format).Parameters
- options: PreloadTilesOptions
The options for preloading tiles by tile IDs.
Returns Promise<void>
A promise that resolves when the preloading is complete.
- options: PreloadTilesOptions
MaptilerpreloadForBounds
-
Preloads all tiles within a geographic bounds across a range of zoom levels.
Parameters
- options: PreloadTilesForBoundsOptions
Options for preloading tiles for bounds.
Returns Promise<void>
A promise that resolves when the preloading is complete.
- options: PreloadTilesForBoundsOptions
MaptilerpreloadForCameraPositions
-
preloadForCameraPositions(
__namedParameters: PreloadTilesForCameraPositionsOptions,
): Promise<TileCoord[]>Preloads tiles visible from each of the given camera positions.
Parameters
- __namedParameters: PreloadTilesForCameraPositionsOptions
Returns Promise<TileCoord[]>
MaptilerpreloadForLinearPath
-
Preloads tiles along a linear camera path (used by panTo and easeTo overrides).
Parameters
- options: PreloadTilesForLinearPathOptions
The options for preloading tiles along a linear camera path.
Returns Promise<TileCoord[]>
A promise that resolves when the preloading is complete.
- options: PreloadTilesForLinearPathOptions
Handles tile preloading for a Map instance.
Prefetches tiles for every active tile source in the current style and stores them in the SDK tile cache so MapLibre can render them without a network round-trip.
Preload strategies include geographic bounds with a zoom range (
preloadForBounds), prefetch a tilePyramid for a LatLngBounds (preloadForCameraPositions), a sampled linear camera path (preloadForLinearPath), and explicit"z/x/y"tile IDs (preloadByTileIDs). Each method returns aPromisethat resolves when the preloading is complete. CallabortAll()to cancel in-flight requests.Remarks
API Key Usage: Every tile fetched by this class counts against your MapTiler Cloud API key quota. Prefer narrow zoom ranges and small geographic areas where possible, and use the
onProgresscallback to monitor consumption.If you update the version of the tile preloader, please update the version in the
EXPERIMENTAL_TILE_PRELOADING_VERSIONconstant.Example