Class: MapEvents
- Last UpdatedMay 21, 2025
- 3 minute read
H.mapevents.MapEvents
MapEvents
enables the events functionality on the map and on map
objects. The class makes it possible to listen to events on map objects such
as markers, polylines, polygons, circles and on the map object itself.
Events are triggered by user interaction, for example clicking or tapping on
the map. Please check the Events Summary section for the list of events fired
by this class and by the map objects.
Name | Type | Description |
---|---|---|
map |
H.Map |
An object representing the map used for firing events |
Example
// prerequisites: mapInstance and marker is initialized
mapInstance.addObject(marker);
var mapevts = new H.mapevents.MapEvents(mapInstance);
// add listener to map
mapInstance.addEventListener('pointermove', function(e) {...});
// add listener to the marker
marker.addEventListener('pointerenter', function(e) {...});
marker.addEventListener('pointerleave', function(e) {...});
Extends
Methods
-
addOnDisposeCallback (callback, opt_scope) inherited
-
This method adds a callback which to be triggered when an object is disposed.
Name Type Description callback
function A callback function to add
opt_scope
Object optional An object representing the scope
-
This method destroys the
MapEvents
instance by removing all handlers from the map object. After calling this method,mapEvents
and map objects do not trigger any events. This object is disposed of automatically when the corresponding map object is disposed of. -
disposeInternal () inherited
-
Performs appropriate cleanup.
-
getAttachedMap ()H.Map
-
This method retrieves the map object to which events are attached.
Returns:
Type Description H.Map
Events
-
This event is dispatched on a target after a right click on the desktop or a longpress on a touch device, but no other pointers were pressed.
Type:
-
This event is dispatched after a "contextmenu" event, if there was any user interaction within the map viewport ("mousedown", "touchstart", "pointerdown" or "wheel").
The context menu UI component should stop propagation of the aforementioned events to prevent firing of "contextmenuclose" while the user interacts with the context menu.
Type:
-
This event type signifies that the pointer (touch, pen) has touched the map (or object) surface twice in a row for a moment.
Type:
-
This event type signifies that the pointer (mouse, pen, touch) is dragging the target. This event is only fired if the target object has
draggable
property set to true.Type:
-
This event type signifies that the pointer (mouse, pen, touch) stopped dragging the target. This event is only fired if the target object has
draggable
property set totrue
.Type:
-
This event type signifies that the pointer (mouse, pen, touch) started dragging the target. This event is only fired if the target object has
draggable
property set totrue
.Type:
-
This event is dispatched on the pointer target after pointerdown has occurred and no pointerup was triggered and pointer stayed in place for a longer time.
Type:
-
This event type signifies that the pointer (mouse, pen, touch) event has been cancelled by the browser. It is equivalent to platform-specific events touchcancel, pointercancel.
Type:
-
This event type signifies that the pointer (mouse, pen, touch) has reached the map surface. It is equivalent to platform-specific events mousedown, touchstart, pointerdown.
Type:
-
This event type signifies that the pointer (mouse, pen, touch) has entered the object area. It is equivalent to platform-specific events mouseenter, touchenter, pointerenter. Note: this event is not propagated to the
mapEvents
object if triggered by a map object (for example marker).Type:
-
This event type signifies that the pointer (mouse, pen, touch) has left the target object area. It is equivalent to platform-specific events mouseleave, touchleave, pointerleave. Note: this event is not propagated to the
mapEvents
object if triggered by a map object (for example marker).Type:
-
This event type signifies that the pointer (mouse, pen, touch) has been moved across the screen (and the map). It is equivalent to platform-specific events mousemove, touchmove, pointermove.
Type:
-
This event type signifies that the pointer (mouse, pen, touch) has left the map surface. It is equivalent to platform-specific events mouseup, touchend, pointerup.
Type:
-
This event type signifies that the pointer (touch, pen, mouse) has touched the map (or object) surface for a moment.
Type: