Events

The different types of events that TrackAsia GL JS can raise.

You can also find additional event documentation for: Map, Marker, Popup, and GeolocationControl.

Evented

src/util/evented.ts

Methods mixed in to other classes for event capabilities.

Instance Members

MapMouseEvent

src/ui/events.ts

MapMouseEvent is the event type for mouse-related map events.

Extends Event.

Example

// The `click` event is an example of a `MapMouseEvent`.
// Set up an event listener on the map.
map.on('click', function(e) {
// The event object (e) contains information like the
// coordinates of the point on the map that was clicked.
console.log('A click event has occurred at ' + e.lngLat);
});

Instance Members

MapTouchEvent

src/ui/events.ts

MapTouchEvent is the event type for touch-related map events.

Extends Event.

Instance Members

MapLibreZoomEvent

src/ui/events.ts

A MapLibreZoomEvent is the event type for the boxzoom-related map events emitted by the BoxZoomHandler.

Properties

originalEvent(MouseEvent): The DOM event that triggered the boxzoom event. Can be a MouseEvent or KeyboardEvent
type(string): The type of boxzoom event. One of boxzoomstart , boxzoomend or boxzoomcancel
target(Map): The Map instance that triggered the event

MapDataEvent

src/ui/events.ts

A MapDataEvent object is emitted with the Map.event:data and Map.event:dataloading events. Possible values for dataTypes are:

  • 'source': The non-tile data associated with any source
  • 'style': The style used by the map

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)

Properties

type(string): The event type.
dataType(string): The type of data that has changed. One of 'source' , 'style' .
isSourceLoaded(boolean?): True if the event has a dataType of source and the source has no outstanding network requests.
source(Object?): The style spec representation of the source if the event has a dataType of source .
sourceDataType(string?): 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 .
tile(Object?): The tile being loaded or changed, if the event has a dataType of source and the event is related to loading of a tile.
coord(Coordinates?): The coordinate of the tile if the event has a dataType of source and the event is related to loading of a tile.

Example

// The sourcedata event is an example of MapDataEvent.
// Set up an event listener on the map.
map.on('sourcedata', function(e) {
if (e.isSourceLoaded) {
// Do something when the source has finished loading
}
});

MapWheelEvent

src/ui/events.ts

MapWheelEvent is the event type for the wheel map event.

Extends Object.

Instance Members