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 MapSourceDataEvent

A MapSourceDataEvent is emitted with the source-related data, dataloading, dataabort, sourcedata, sourcedataloading and sourcedataabort events. Its dataType is always 'source'.

Possible values for sourceDataTypes are:

  • 'metadata': indicates that any necessary source metadata has been loaded (such as TileJSON) and it is ok to start loading tiles
  • 'content': indicates the source data has changed (such as when source.setData() has been called on GeoJSONSource)
  • 'visibility': send when the source becomes used when at least one of its layers becomes visible in style sense (inside the layer's zoom range and with layout.visibility set to 'visible')
  • 'idle': indicates that no new source data has been fetched (but the source has done loading)
// The sourcedata event is an example of a MapSourceDataEvent.
// Set up an event listener on the map.
map.on('sourcedata', (e) => {
   if (e.isSourceLoaded) {
       // Do something when the source has finished loading
   }
});

Hierarchy (View Summary)

Index

Constructors

  • Parameters

    • type:
          | "dataloading"
          | "data"
          | "sourcedataloading"
          | "sourcedata"
          | "dataabort"
          | "sourcedataabort"
    • Optionaldata: Omit<Partial<MapSourceDataEvent>, "type" | "dataType" | "target">

    Returns MapSourceDataEvent

Properties

The tile ID of the tile being loaded or changed, if the event is related to loading of a tile.

dataType: "source"
isSourceLoaded: boolean

True if the event has a dataType of source and the source has no outstanding network requests.

originalEvent: unknown
resourceTiming?: PerformanceResourceTiming[]

Resource timing data, if collectResourceTiming is enabled for the source.

The style spec representation of the source if the event has a dataType of source.

sourceDataChanged?: boolean
sourceDataType: MapSourceDataType
sourceId: string
target: MapMLGL

The object that fired the event. Set when the event is fired, and narrowed to a more specific type (e.g. Map, Marker) by the event subclasses.

tile: any

The tile being loaded or changed, if the event has a dataType of source and the event is related to loading of a tile.

type:
    | "dataloading"
    | "data"
    | "sourcedataloading"
    | "sourcedata"
    | "dataabort"
    | "sourcedataabort"
Was this helpful?