Skip to content

Class: MapMouseEvent

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

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);
});

Hierarchy

MapMouseEvent

Implements

Accessors

defaultPrevented

get defaultPrevented(): boolean

true if preventDefault has been called.

Returns

boolean

Defined in

src/ui/events.ts:519

Methods

preventDefault

preventDefault(): void

Prevents subsequent default processing of the event by the map.

Calling this method will prevent the following default map behaviors:

Returns

void

Defined in

src/ui/events.ts:512

Properties

lngLat

lngLat: LngLat

The geographic location on the map of the mouse cursor.

Defined in

src/ui/events.ts:499


originalEvent

originalEvent: MouseEvent

The DOM event which caused the map event.

Implementation of

MapLibreEvent.originalEvent

Defined in

src/ui/events.ts:489


point

point: Point

The pixel coordinates of the mouse cursor, relative to the map and measured from the top left corner.

Defined in

src/ui/events.ts:494


target

target: Map

The Map object that fired the event.

Implementation of

MapLibreEvent.target

Defined in

src/ui/events.ts:484


type

type: "click" | "contextmenu" | "dblclick" | "mousedown" | "mouseenter" | "mouseleave" | "mousemove" | "mouseout" | "mouseover" | "mouseup"

The event type

Implementation of

MapLibreEvent.type

Overrides

Event.type

Defined in

src/ui/events.ts:479