Events
The different types of events that SDK JS can raise.
You can also find additional event documentation for: Map
, Marker
, Popup
, and GeolocationControl
.
Evented
Methods mixed in to other classes for event capabilities.
Methods
Returns a true if this instance of Evented or any forwarded instances of Evented has a listener for the specified type.
boolean
:
true
if there is at least one registered listener
for specified event type, false
otherwise
Adds a listener to a specified event type.
Parameters
(Function)
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
Object
:
this
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.
Parameters
Returns
Object
:
this
Bubble all events fired by this instance of Evented to this parent instance of Evented.
Parameters
(Evented)
(any)
Returns
Object
:
this
MapMouseEvent
MapMouseEvent
is the event type for mouse-related map events.
Example
Methods
The geographic location on the map of the mouse cursor.
The DOM event which caused the map event.
The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.
Prevents subsequent default processing of the event by the map.
Calling this method will prevent the following default map behaviors:
- On
mousedown
events, the behavior of DragPanHandler - On
mousedown
events, the behavior of DragRotateHandler - On
mousedown
events, the behavior of BoxZoomHandler - On
dblclick
events, the behavior of DoubleClickZoomHandler
The Map
object that fired the event.
MapTouchEvent
MapTouchEvent
is the event type for touch-related map events.
Methods
The geographic location on the map of the center of the touch event points.
The geographical locations on the map corresponding to a
touch event's
touches
property.
The DOM event which caused the map event.
The pixel coordinates of the center of the touch event points, relative to the map and measured from the top left corner.
The array of pixel coordinates corresponding to a
touch event's
touches
property.
Prevents subsequent default processing of the event by the map.
Calling this method will prevent the following default map behaviors:
- On
touchstart
events, the behavior of DragPanHandler - On
touchstart
events, the behavior of TouchZoomRotateHandler
The Map
object that fired the event.
The event type.
MapLibreZoomEvent
A MapLibreZoomEvent
is the event type for the boxzoom-related map events emitted by the BoxZoomHandler.
Properties
(MouseEvent)
:
The DOM event that triggered the boxzoom event. Can be a
MouseEvent
or
KeyboardEvent
MapDataEvent
A MapDataEvent
object is emitted with the Map.event:data
and Map.event:dataloading events. Possible
values for
dataType
s are:
'source'
: The non-tile data associated with any source'style'
: The style used by the map
Example
Properties
(boolean?)
:
True if the event has a
dataType
of
source
and the source has no outstanding network requests.
(Object?)
:
The
style spec representation of the
source
if the event has a
dataType
of
source
.
(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
and
visibility
.
(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.
(Coordinates?)
:
The coordinate of the tile if the event has a
dataType
of
source
and
the event is related to loading of a tile.
MapWheelEvent
MapWheelEvent
is the event type for the wheel
map event.
Methods
The DOM event which caused the map event.
Prevents subsequent default processing of the event by the map.
Calling this method will prevent the the behavior of ScrollZoomHandler.
The Map
object that fired the event.
The event type.