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 StyleMLGL
Hierarchy (View Summary)
- Evented<MapEventType>
- StyleMLGL
Index
Constructors
Properties
Methods
Constructors
constructor
Parameters
- map: MapMLGL
Optionaloptions: StyleOptions
Returns StyleMLGL
Properties
crossTileSymbolIndex
dispatcher
glyphManager
imageManager
light
lineAtlas
map
patternAtlas
pauseablePlacement
placement
projection
sky
stylesheet
tileManagers
z
zoomHistory
Methods
addImage
Parameters
- id: string
- image: StyleImage
Returns void
addLayer
Add a layer to the map style. The layer will be inserted before the layer with ID
before, or appended ifbeforeis omitted.Parameters
- layerObject: AddLayerObject
The style layer to add.
Optionalbefore: stringID of an existing layer to insert before
Optionaloptions: StyleSetterOptionsStyle setter options.
Returns this
- layerObject: AddLayerObject
addSource
- addSource(
id: string,
source: SourceSpecification | CanvasSourceSpecification,
options?: StyleSetterOptions,
): voidParameters
- id: string
- source: SourceSpecification | CanvasSourceSpecification
Optionaloptions: StyleSetterOptions
Returns void
addSprite
- addSprite(
id: string,
url: string,
options?: StyleSetterOptions,
completion?: (err: Error) => void,
): voidAdd a sprite.
Parameters
- id: string
The id of the desired sprite
- url: string
The url to load the desired sprite from
Optionaloptions: StyleSetterOptionsThe style setter options
Optionalcompletion: (err: Error) => voidThe completion handler
Returns void
- id: string
destroy
Destroys all internal resources of the style (sources, images, layers, etc.)
Returns void
fire
- fire(
event:
| ErrorEvent
| MapMovementEvent
| MapStyleLoadEvent
| MapLibreEvent<unknown>
| MapStyleDataEvent
| MapSourceDataEvent
| MapBoxZoomEvent
| MapTerrainEvent
| MapProjectionEvent
| MapContextEvent
| MapStyleImageMissingEvent
| MapMouseEventMLGL
| MapTouchEventMLGL
| MapWheelEventMLGL
| MapLibreEvent<TouchEvent | WheelEvent> & {
gestureType: "wheel_zoom" | "touch_pan";
},
): thisCalls every listener registered for the event's type.
Parameters
- event:
| ErrorEvent
| MapMovementEvent
| MapStyleLoadEvent
| MapLibreEvent<unknown>
| MapStyleDataEvent
| MapSourceDataEvent
| MapBoxZoomEvent
| MapTerrainEvent
| MapProjectionEvent
| MapContextEvent
| MapStyleImageMissingEvent
| MapMouseEventMLGL
| MapTouchEventMLGL
| MapWheelEventMLGL
| MapLibreEvent<TouchEvent | WheelEvent> & {
gestureType: "wheel_zoom" | "touch_pan";
}
Returns this
- event:
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 MapEventType
Optionalproperties: object
Returns this
getDashes
Parameters
- mapId: string | number
- params: GetDashesParameters
Returns Promise<GetDashesResponse>
getFeatureState
Parameters
- target: FeatureIdentifier
Returns FeatureState
getFilter
Get a layer's filter object
Parameters
- layer: string
the layer to inspect
Returns void | FilterSpecification
the layer's filter, if any
- layer: string
getFontFaces
Returns FontFacesSpecification | null
getGlobalState
Returns Record<string, any>
getGlyphs
Parameters
- mapId: string | number
- params: GetGlyphsParameters
Returns Promise<GlyphMap>
getGlyphsUrl
Returns string | null
getImage
Parameters
- id: string
Returns StyleImage
getImages
Parameters
- mapId: string | number
- params: GetImagesParameters
Returns Promise<GetImagesResponse>
getLayer
Return the style layer object with the given
id.Parameters
- id: string
id of the desired layer
Returns StyleLayer | undefined
a layer, if one with the given
idexists- id: string
getLayersOrder
Return the ids of all layers currently in the style, including custom layers, in order.
Returns string[]
ids of layers, in order
getLayoutProperty
- getLayoutProperty<K extends keyof AllLayoutProperties>(
layerId: string,
name: K,
): AllLayoutProperties[K] | undefinedGet a layout property's value from a given layer
Type Parameters
- K extends keyof AllLayoutProperties
Parameters
- layerId: string
the layer to inspect
- name: K
the name of the layout property
Returns AllLayoutProperties[K] | undefined
the property value
getLight
Returns LightSpecification
getPaintProperty
- getPaintProperty<K extends keyof AllPaintProperties>(
layer: string,
name: K,
): AllPaintProperties[K]Type Parameters
- K extends keyof AllPaintProperties
Parameters
- layer: string
- name: K
Returns AllPaintProperties[K]
getProjection
Returns ProjectionSpecification
getSky
Returns SkySpecification
getSource
getSprite
Get the current sprite value.
Returns { id: string; url: string }[]
empty array when no sprite is set; id-url pairs otherwise
getTransition
Returns { delay: number; duration: number } & TransitionSpecification
hasLayer
Checks if a specific layer is present within the style.
Parameters
- id: string
the id of the desired layer
Returns boolean
a boolean specifying if the given layer is present
- id: string
hasTransitions
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 MapEventType
The event type
Returns boolean
trueif there is at least one registered listener for specified event type,falseotherwise- type: keyof MapEventType
listImages
Returns string[]
loaded
Returns boolean
loadEmpty
Returns void
loadJSON
- loadJSON(
json: StyleSpecification,
options?: StyleSetterOptions & StyleSwapOptions,
previousStyle?: StyleSpecification,
): voidParameters
- json: StyleSpecification
Optionaloptions: StyleSetterOptions & StyleSwapOptionsOptionalpreviousStyle: StyleSpecification
Returns void
loadURL
- loadURL(
url: string,
options?: StyleSwapOptions & StyleSetterOptions,
previousStyle?: StyleSpecification,
): Promise<void>Parameters
- url: string
Optionaloptions: StyleSwapOptions & StyleSetterOptionsOptionalpreviousStyle: StyleSpecification
Returns Promise<void>
moveLayer
Moves a layer to a different z-position. The layer will be inserted before the layer with ID
before, or appended ifbeforeis omitted.Parameters
- id: string
ID of the layer to move
Optionalbefore: stringID of an existing layer to insert before
Returns void
- id: string
off
Removes a previously registered event listener.
Type Parameters
- T extends keyof MapEventType
Parameters
- type: T
The event type to remove listeners for.
- listener: (event: MapEventType[T]) => void
The listener function to remove.
Returns this
on
- on<T extends keyof MapEventType>(
type: T,
listener: (event: MapEventType[T]) => void,
): SubscriptionAdds a listener to a specified event type.
Type Parameters
- T extends keyof MapEventType
Parameters
- type: T
The event type to add a listen for.
- listener: (event: MapEventType[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
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 MapEventType
Parameters
- type: T
The event type to listen for.
Returns Promise<MapEventType[T]>
a promise that resolves with the event
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 MapEventType
Parameters
- type: T
The event type to listen for.
- listener: (event: MapEventType[T]) => void
The function to be called when the event is fired the first time.
Returns this
thiswhen a listener is provided
queryRenderedFeatures
- queryRenderedFeatures(
queryGeometry: Point[],
params: QueryRenderedFeaturesOptions,
transform: IReadonlyTransform,
): MapGeoJSONFeature[]Parameters
- queryGeometry: Point[]
- params: QueryRenderedFeaturesOptions
- transform: IReadonlyTransform
Returns MapGeoJSONFeature[]
querySourceFeatures
Parameters
- sourceID: string
Optionalparams: QuerySourceFeatureOptions
Returns GeoJSONFeature[]
removeFeatureState
Parameters
- target: FeatureIdentifier
Optionalkey: string
Returns void
removeImage
Parameters
- id: string
Returns void
removeLayer
Remove the layer with the given id from the style. A ErrorEvent event will be fired if no such layer exists.
Parameters
- id: string
id of the layer to remove
Returns void
- id: string
removeSource
removeSprite
Remove a sprite by its id. When the last sprite is removed, the whole
this.stylesheet.spriteobject becomesundefined. This falsyundefinedvalue later prevents attempts to load the sprite when it's absent.Parameters
- id: string
the id of the sprite to remove
Returns void
- id: string
serialize
Returns StyleSpecification | undefined
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
Parameters
- target: FeatureIdentifier
- state: any
Returns void
setFilter
- setFilter(
layerId: string,
filter?: FilterSpecification | null,
options?: StyleSetterOptions,
): voidParameters
- layerId: string
Optionalfilter: FilterSpecification | nullOptionaloptions: StyleSetterOptions
Returns void
setFontFaces
Parameters
- fontFaces: FontFacesSpecification | null | undefined
Returns void
setGeoJSONSourceData
Set the data of a GeoJSON source, given its id.
Parameters
- id: string
id of the source
- data: string | GeoJSON<Geometry, GeoJsonProperties>
GeoJSON source
Returns void
- id: string
setGlobalState
Parameters
- newStylesheetState: StateSpecification
Returns void
setGlobalStateProperty
Parameters
- name: string
- value: any
Returns this
setGlyphs
Parameters
- glyphsUrl: string | null | undefined
Optionaloptions: StyleSetterOptions
Returns void
setLayerZoomRange
Parameters
- layerId: string
Optionalminzoom: number | nullOptionalmaxzoom: number | null
Returns void
setLayoutProperty
- setLayoutProperty<K extends keyof AllLayoutProperties>(
layerId: string,
name: K,
value: AllLayoutProperties[K],
options?: StyleSetterOptions,
): voidType Parameters
- K extends keyof AllLayoutProperties
Parameters
- layerId: string
- name: K
- value: AllLayoutProperties[K]
Optionaloptions: StyleSetterOptions
Returns void
setLight
Parameters
- lightOptions: LightSpecification
Optionaloptions: StyleSetterOptions
Returns void
setMissingImageResolver
Parameters
- resolver: MissingImageRequestHandler | null
Returns void
setPaintProperty
- setPaintProperty<K extends keyof AllPaintProperties>(
layerId: string,
name: K,
value: AllPaintProperties[K],
options?: StyleSetterOptions,
): voidType Parameters
- K extends keyof AllPaintProperties
Parameters
- layerId: string
- name: K
- value: AllPaintProperties[K]
Optionaloptions: StyleSetterOptions
Returns void
setProjection
Parameters
Optionalprojection: ProjectionSpecification
Returns void
setSky
Parameters
OptionalskyOptions: SkySpecificationOptionaloptions: StyleSetterOptions
Returns void
setSprite
- setSprite(
sprite: SpriteSpecification,
options?: StyleSetterOptions,
completion?: (err: Error) => void,
): voidSet a new value for the style's sprite.
Parameters
- sprite: SpriteSpecification
new sprite value
Optionaloptions: StyleSetterOptionsstyle setter options
Optionalcompletion: (err: Error) => voidthe completion handler
Returns void
- sprite: SpriteSpecification
setState
Update this style's state to match the given style JSON, performing only the necessary mutations.
May throw an Error ('Unimplemented: METHOD') if the maplibre-gl-style-spec diff algorithm produces an operation that is not supported.
Parameters
- nextState: StyleSpecification
Optionaloptions: StyleSwapOptions & StyleSetterOptions
Returns boolean
true if any changes were made; false otherwise
triggerSymbolPlacement
Re-places symbols on the next frame. Placement is skipped while its inputs look unchanged, so call this when something the map cannot see for itself has moved symbols.
Returns void
update
Parameters
- parameters: EvaluationParameters
Returns void
updateImage
Parameters
- id: string
- image: StyleImage
Returns void
The Style base class