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

The Style base class

Hierarchy (View Summary)

Index

Constructors

Properties

crossTileSymbolIndex: CrossTileSymbolIndex
dispatcher: Dispatcher
glyphManager: GlyphManager
imageManager: ImageManager
light: Light
lineAtlas: LineAtlas
map: MapMLGL
patternAtlas: PatternAtlas
pauseablePlacement: PauseablePlacement
placement: Placement
projection: Projection | undefined
sky: Sky
stylesheet: StyleSpecification
tileManagers: { [_: string]: TileManager }
z: number
zoomHistory: ZoomHistory

Methods

  • Add a layer to the map style. The layer will be inserted before the layer with ID before, or appended if before is omitted.

    Parameters

    • layerObject: AddLayerObject

      The style layer to add.

    • Optionalbefore: string

      ID of an existing layer to insert before

    • Optionaloptions: StyleSetterOptions

      Style setter options.

    Returns this

  • Add a sprite.

    Parameters

    • id: string

      The id of the desired sprite

    • url: string

      The url to load the desired sprite from

    • Optionaloptions: StyleSetterOptions

      The style setter options

    • Optionalcompletion: (err: Error) => void

      The completion handler

    Returns void

  • Destroys all internal resources of the style (sources, images, layers, etc.)

    Returns void

  • Returns Record<string, any>

  • Returns string | null

  • 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 id exists

  • Return the ids of all layers currently in the style, including custom layers, in order.

    Returns string[]

    ids of layers, in order

  • Get a source by ID.

    Parameters

    • id: string

      ID of the desired source

    Returns Source | undefined

    source

  • Get the current sprite value.

    Returns { id: string; url: string }[]

    empty array when no sprite is set; id-url pairs otherwise

  • 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

  • Returns boolean

  • Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.

    Parameters

    Returns boolean

    true if there is at least one registered listener for specified event type, false otherwise

  • Returns string[]

  • Returns boolean

  • Returns void

  • Moves a layer to a different z-position. The layer will be inserted before the layer with ID before, or appended if before is omitted.

    Parameters

    • id: string

      ID of the layer to move

    • Optionalbefore: string

      ID of an existing layer to insert before

    Returns void

  • Removes a previously registered event listener.

    Type Parameters

    Parameters

    • type: T

      The event type to remove listeners for.

    • listener: (event: MapEventType[T]) => void

      The listener function to remove.

    Returns this

  • Adds a listener to a specified event type.

    Type Parameters

    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 with target and type properties.

    Returns Subscription

  • 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

    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

    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

    this when a listener is provided

  • Parameters

    • id: string

    Returns void

  • 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

  • Remove a source from this stylesheet, given its id.

    Parameters

    • id: string

      id of the source to remove

    Returns this

    if no source is found with the given ID

  • Remove a sprite by its id. When the last sprite is removed, the whole this.stylesheet.sprite object becomes undefined. This falsy undefined value later prevents attempts to load the sprite when it's absent.

    Parameters

    • id: string

      the id of the sprite to remove

    Returns void

  • Parameters

    • name: string
    • value: any

    Returns this

  • Parameters

    Returns void

  • Parameters

    • layerId: string
    • Optionalminzoom: number | null
    • Optionalmaxzoom: number | null

    Returns void

  • 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

Was this helpful?