---
title: "MapSourceDataEvent | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/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 `sourceDataType`s 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)

#### Example[](#example)

```typescript
// 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](https://docs.maptiler.com/sdk-js/api-reference/hierarchy/#MapSourceDataEvent))

-   [MapLibreEvent](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/)
    -   MapSourceDataEvent

##### Index

### Constructors

[constructor](#constructor)

### Properties

[coord](#coord) [dataType](#datatype) [isSourceLoaded](#issourceloaded) [originalEvent](#originalevent) [resourceTiming?](#resourcetiming) [source](#source) [sourceDataChanged?](#sourcedatachanged) [sourceDataType](#sourcedatatype) [sourceId](#sourceid) [target](#target) [tile](#tile) [type](#type)

## Constructors

### constructor[](#constructor)

-   new MapSourceDataEvent(  
        type:  
            | "dataloading"  
            | "data"  
            | "sourcedataloading"  
            | "sourcedata"  
            | "dataabort"  
            | "sourcedataabort",  
        data?: [Omit](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Omit/)<[Partial](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Partial/)<MapSourceDataEvent\>, "type" | "dataType" | "target"\>,  
    ): MapSourceDataEvent[](#constructormapsourcedataevent)
    
    #### Parameters
    
    -   type:  
            | "dataloading"  
            | "data"  
            | "sourcedataloading"  
            | "sourcedata"  
            | "dataabort"  
            | "sourcedataabort"
    -   `Optional`data: [Omit](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Omit/)<[Partial](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Partial/)<MapSourceDataEvent\>, "type" | "dataType" | "target"\>
    
    #### Returns MapSourceDataEvent
    
    Overrides [MapLibreEvent](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/).[constructor](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/#constructor)
    

## Properties

### coord[](#coord)

coord: [OverscaledTileID](https://docs.maptiler.com/sdk-js/api-reference/interfaces/OverscaledTileID/)

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

### dataType[](#datatype)

dataType: "source"

### isSourceLoaded[](#issourceloaded)

isSourceLoaded: boolean

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

### originalEvent[](#originalevent)

originalEvent: unknown

Inherited from [MapLibreEvent](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/).[originalEvent](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/#originalevent)

### `Optional`resourceTiming[](#resourcetiming)

resourceTiming?: PerformanceResourceTiming\[\]

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

### source[](#source)

source: [SourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/SourceSpecification/)

The [style spec representation of the source](https://maplibre.org/maplibre-style-spec/#sources) if the event has a `dataType` of `source`.

### `Optional`sourceDataChanged[](#sourcedatachanged)

sourceDataChanged?: boolean

### sourceDataType[](#sourcedatatype)

sourceDataType: [MapSourceDataType](https://docs.maptiler.com/sdk-js/api-reference/types/MapSourceDataType/)

### sourceId[](#sourceid)

sourceId: string

### target[](#target)

target: [MapMLGL](https://docs.maptiler.com/sdk-js/api-reference/classes/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.

Inherited from [MapLibreEvent](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/).[target](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/#target)

### tile[](#tile)

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[](#type)

type:  
    | "dataloading"  
    | "data"  
    | "sourcedataloading"  
    | "sourcedata"  
    | "dataabort"  
    | "sourcedataabort"

Overrides [MapLibreEvent](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/).[type](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreEvent/#type)
