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 TileManager
Hierarchy (View Summary)
- Evented<SourceEventType>
- TileManager
Index
Constructors
Properties
Methods
Constructors
constructor
- new TileManager(
id: string,
options: SourceSpecification | CanvasSourceSpecification,
dispatcher: Dispatcher,
): TileManagerParameters
- id: string
- options: SourceSpecification | CanvasSourceSpecification
- dispatcher: Dispatcher
Returns TileManager
Properties
dispatcher
id
map
style
terrain
tileSize
transform
used
usedForTerrain
StaticmaxOverzooming
StaticmaxUnderzooming
Methods
areTilesLoaded
Returns boolean
clearTiles
Remove all tiles from this pyramid
Returns void
fire
Calls every listener registered for the event's type.
Parameters
- event: ErrorEvent | MapSourceDataEvent
Returns this
Compatibility with the (type: string, properties: Object) signature from previous versions. See https://github.com/mapbox/mapbox-gl-js/issues/6522, https://github.com/mapbox/mapbox-gl-draw/issues/766
Parameters
- type: keyof SourceEventType
Optionalproperties: object
Returns this
getFeatureState
Get the entire state object for a feature
Parameters
- sourceLayer: string
- featureId: string | number
Returns FeatureState
getIds
Return all tile ids ordered with z-order, and cast to numbers
Returns string[]
getLoadedTile
Get a currently loaded tile.
- a cached tile is not a loaded tile
Parameters
- tileID: OverscaledTileID
Returns Tile | null
the tile if it's in view and had data, null otherwise.
getRenderableIds
Parameters
OptionalsymbolLayer: boolean
Returns string[]
getSource
Returns Source
getState
Returns SourceFeatureState
getTile
getTileByID
getVisibleCoordinates
Parameters
OptionalsymbolLayer: boolean
Returns OverscaledTileID[]
handleWrapJump
Parameters
- lng: number
Returns void
hasRenderableParent
Parameters
- tileID: OverscaledTileID
Returns boolean
hasTransition
Returns boolean
listens
Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
Parameters
- type: keyof SourceEventType
The event type
Returns boolean
trueif there is at least one registered listener for specified event type,falseotherwise- type: keyof SourceEventType
loaded
Return true if no tile data is pending, tiles will not change unless an additional API call is received.
Returns boolean
off
- off<T extends keyof SourceEventType>(
type: T,
listener: (event: SourceEventType[T]) => void,
): thisRemoves a previously registered event listener.
Type Parameters
- T extends keyof SourceEventType
Parameters
- type: T
The event type to remove listeners for.
- listener: (event: SourceEventType[T]) => void
The listener function to remove.
Returns this
on
- on<T extends keyof SourceEventType>(
type: T,
listener: (event: SourceEventType[T]) => void,
): SubscriptionAdds a listener to a specified event type.
Type Parameters
- T extends keyof SourceEventType
Parameters
- type: T
The event type to add a listen for.
- listener: (event: SourceEventType[T]) => void
The function to be called when the event is fired. The listener function is called with the data object passed to
fire, extended withtargetandtypeproperties.
Returns Subscription
onAdd
Parameters
- map: MapMLGL
Returns void
once
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.
Type Parameters
- T extends keyof SourceEventType
Parameters
- type: T
The event type to listen for.
Returns Promise<SourceEventType[T]>
a promise that resolves with the event
- once<T extends keyof SourceEventType>(
type: T,
listener: (event: SourceEventType[T]) => void,
): thisAdds 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.
Type Parameters
- T extends keyof SourceEventType
Parameters
- type: T
The event type to listen for.
- listener: (event: SourceEventType[T]) => void
The function to be called when the event is fired the first time.
Returns this
thiswhen a listener is provided
onRemove
Parameters
- map: MapMLGL
Returns void
pause
Returns void
prepare
Parameters
- context: Context
Returns void
refreshTiles
Reload any currently renderable tiles that are match one of the incoming
tileIdx/y/zParameters
- tileIds: ICanonicalTileID[]
Returns void
releaseSymbolFadeTiles
Returns void
reload
Reload tiles based on the current state of the source.
Parameters
OptionalsourceDataChanged: booleanIf
true, reload all tiles using a state of 'expired' (errored tiles use 'loading' since they have nothing to show yet), otherwise reload only non-errored tiles using state of 'reloading'.OptionalshouldReloadTileOptions: anySet of options associated with a
MapSourceDataChangedEventthat can be passed back to the associatedSourcedetermine whether a tile should be reloaded.
Returns void
reloadTilesForDependencies
Reloads all tiles that depend on the given keys.
Parameters
- namespaces: string[]
- keys: string[]
Returns void
removeFeatureState
Resets the value of a particular state key for a feature
Parameters
OptionalsourceLayer: stringOptionalfeatureId: string | numberOptionalkey: string
Returns void
resetMaxContentElevation
Forgets the recorded maximum content elevation, so the next update recomputes it from the current layers and loaded tiles. Called when a symbol layer is removed, since the removed layer's heights would otherwise keep expanding tile coverage.
Returns void
resume
Returns void
serialize
Returns any
setDependencies
Sets the set of keys that the tile depends on. This allows tiles to be reloaded when their dependencies change.
Parameters
- tileKey: string
- namespace: string
- dependencies: string[]
Returns void
setEventedParent
- setEventedParent(
parent?: Evented<EventTypeMap> | null,
data?: EventedParentData | (() => EventedParentData),
): thisBubble all events fired by this instance of Evented to this parent instance of Evented.
Parameters
Optionalparent: Evented<EventTypeMap> | nullOptionaldata: EventedParentData | (() => EventedParentData)
Returns this
setFeatureState
Set the value of a particular state for a feature
Parameters
- sourceLayer: string
- featureId: string | number
- state: any
Returns void
setRasterFadeDuration
Parameters
- fadeDuration: number
Returns void
tilesIn
- tilesIn(
pointQueryGeometry: Point[],
maxPitchScaleFactor: number,
has3DLayer: boolean,
): TileResult[]Search through our current tiles and attempt to find the tiles that cover the given bounds.
Parameters
- pointQueryGeometry: Point[]
coordinates of the corners of bounding rectangle
- maxPitchScaleFactor: number
- has3DLayer: boolean
Returns TileResult[]
result items have
{tile, minX, maxX, minY, maxY}, where min/max bounding values are the given bounds transformed in into the coordinate space of this tile. - pointQueryGeometry: Point[]
update
Removes tiles that are outside the viewport and adds new tiles that are inside the viewport.
Parameters
- transform: ITransform
Optionalterrain: Terrain
Returns void
updateCacheSize
Resizes the tile cache based on the current viewport's size or the maxTileCacheSize option passed during map creation
Larger viewports use more tiles and need larger caches. Larger viewports are more likely to be found on devices with more memory and on pages where the map is more important.
Parameters
- transform: IReadonlyTransform
Returns void
Internal
TileManageris responsible forSourceSourceMapand coordinating updatesPainter