---
title: "MapDataEvent | 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.

# Type Alias MapDataEvent

A `MapDataEvent` object is emitted with the `data` and `dataloading` events. Possible values for `dataType`s are:

-   `'source'`: The non-tile data associated with any source
-   `'style'`: The [style](https://maplibre.org/maplibre-style-spec/) used by the map

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 MapDataEvent.
// Set up an event listener on the map.
map.on('sourcedata', (e) => {
   if (e.isSourceLoaded) {
       // Do something when the source has finished loading
   }
});
```

type MapDataEvent \= {  
    [dataType](#datatype): string;  
    [sourceDataType](#sourcedatatype): [MapSourceDataType](https://docs.maptiler.com/sdk-js/api-reference/types/MapSourceDataType/);  
    [type](#type): string;  
}

##### Index

### Properties[](#properties)

[dataType](#datatype) [sourceDataType](#sourcedatatype) [type](#type)

## Properties[](#properties-1)

### dataType[](#datatype)

dataType: string

The type of data that has changed. One of `'source'`, `'style'`.

### sourceDataType[](#sourcedatatype)

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

Included if the event has a `dataType` of `source` and the event signals that internal data has been received or changed. Possible values are `metadata`, `content`, `visibility` and `idle`.

### type[](#type)

type: string

The event type.
