Atlaslog
Atlaslog / MapLibre GL JS / API / addSprite
MapLibre GL JS · API reference

addSprite

Quick answer

addSprite ( id : string , url : string , options? : StyleSetterOptions ): this

Last verified 2026-11-03 · MapLibre GL JS 4.x · Cite this page
Runnable examplesChinese noteAll API topics
addSprite()

addSprite(id: string, url: string, options?: StyleSetterOptions): this

Defined in: ui/map.ts:3823

Adds a sprite to the map's style. Fires the style event.

Parameters

Parameter Type Description
id string The ID of the sprite to add. Must not conflict with existing sprites.
url string The URL to load the sprite from
options? StyleSetterOptions Options object.

Returns

this

Example

map.addSprite('sprite-two', 'http://example.com/sprite-two');

TutorialsAPI index
English reference text adapted from the official MapLibre GL JS documentation, © MapLibre contributors, licensed under BSD-3-Clause.
Original page: https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/ · Chinese note: /maplibre/api/add-sprite.html
Cite this page

Atlaslog (2026). addSprite. https://www.jingweizhi.com/en/maplibre/api/add-sprite.html (accessed 2026-11-03).