Maps API for JavaScript Developer's Guide

H.mapevents.MapEvents

Class Summary

Extends: H.util.Disposable

MapEvents enable the events functionality on the map and on the map objects. By using this extension it is possible to listen to events on map objects like markers, polylines, polygons, circles and on the map object itself. Events are triggered depending on user interaction. Please check the Events Summary section for the list of events fired by this class and by the map objects.

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

dispose ()

This method destroys the MapEvents by removing all handlers from the map object. After calling this function mapEvents and map objects will not trigger any events. This object will be disposed automatically if the corresponding map object is disposed.

getAttachedMap () : {H.Map}

This method returns map into which events are attached

Events Summary

Table 2. Events
Events

pointerdown : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has reached the map surface. It is equivalent to platform: mousedown, touchstart, pointerdown.

pointerup : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has left the map surface. It is equivalent to platform's: mouseup, touchend, pointerup.

pointermove : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) is moved over the surface. It is equivalent to platform's: mousemove, touchmove, pointermove.

pointerenter : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has entered the object area. It is equivalent to platform's: mouseenter, touchenter, pointerenter. Note: this events is not propagated to the mapEvents object if triggered by the map object (i.e marker).

pointerleave : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has left the target object area. It is equivalent to platform's: mouseleave, touchleave, pointerleave. Note: this events is not propagated to the mapEvents object if triggered by the map object (i.e marker).

pointercancel : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has been cancelled by the browser. It equalivement to platform's: touchcancel, pointercancel.

dragstart : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) started dragging the target. This event is only fired if the target object has draggable property set to true.

drag : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) is dragging the target. This event is only fired if the target object has draggable property set to true.

dragend : {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) stopped dragging the target. This event is only fired if the target object has draggable property set to true.

tap : {H.mapevents.Event}

Signifies this the pointer (touch, pen, mouse) has touched the map (or object) surface for a moment.

dbltap : {H.mapevents.Event}

Signifies this the pointer (touch, pen) has touched the map (or object) surface twice in a row for a moment.

longpress : {H.mapevents.Event}

This event is dispatched on pointer target after pointer down has occurred and no pointer up was triggered and pointer stayed in place for a longer time.

contextmenu : {H.mapevents.ContextMenuEvent}

This event is dispatched on a target after right click on the desktop or a longpress on a touch device, but no other pointers were pressed

contextmenuclose : {H.mapevents.Event}

This event is dispatched after "contextmenu" event, if there was any user interaction within the map's viewport (i.e. "mousedown", "touchstart", "pointerdown" or "wheel").

Class Description

MapEvents enable the events functionality on the map and on the map objects. By using this extension it is possible to listen to events on map objects like markers, polylines, polygons, circles and on the map object itself. Events are triggered depending on user interaction. Please check the Events Summary section for the list of events fired by this class and by the map objects.

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

Constructor Details

H.mapevents.MapEvents(map)

Parameters:
 
map:
{H.Map}
 
map instance which is used for firing events

Method Details

dispose ()

This method destroys the MapEvents by removing all handlers from the map object. After calling this function mapEvents and map objects will not trigger any events. This object will be disposed automatically if the corresponding map object is disposed.

getAttachedMap () : {H.Map}

This method returns map into which events are attached

Returns:
 
{H.Map}

Event Details

pointerdown: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has reached the map surface. It is equivalent to platform: mousedown, touchstart, pointerdown.

pointerup: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has left the map surface. It is equivalent to platform's: mouseup, touchend, pointerup.

pointermove: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) is moved over the surface. It is equivalent to platform's: mousemove, touchmove, pointermove.

pointerenter: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has entered the object area. It is equivalent to platform's: mouseenter, touchenter, pointerenter. Note: this events is not propagated to the mapEvents object if triggered by the map object (i.e marker).

pointerleave: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has left the target object area. It is equivalent to platform's: mouseleave, touchleave, pointerleave. Note: this events is not propagated to the mapEvents object if triggered by the map object (i.e marker).

pointercancel: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) has been cancelled by the browser. It equalivement to platform's: touchcancel, pointercancel.

dragstart: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) started dragging the target. This event is only fired if the target object has draggable property set to true.

drag: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) is dragging the target. This event is only fired if the target object has draggable property set to true.

dragend: {H.mapevents.Event}

Signifies this the pointer (mouse, pen, touch) stopped dragging the target. This event is only fired if the target object has draggable property set to true.

tap: {H.mapevents.Event}

Signifies this the pointer (touch, pen, mouse) has touched the map (or object) surface for a moment.

dbltap: {H.mapevents.Event}

Signifies this the pointer (touch, pen) has touched the map (or object) surface twice in a row for a moment.

longpress: {H.mapevents.Event}

This event is dispatched on pointer target after pointer down has occurred and no pointer up was triggered and pointer stayed in place for a longer time.

contextmenu: {H.mapevents.ContextMenuEvent}

This event is dispatched on a target after right click on the desktop or a longpress on a touch device, but no other pointers were pressed

contextmenuclose: {H.mapevents.Event}

This event is dispatched after "contextmenu" event, if there was any user interaction within the map's viewport (i.e. "mousedown", "touchstart", "pointerdown" or "wheel").

Context menu ui component should stop propagation of aforementioned events within itself, to prevent firing of "contextmenuclose" while user interacts with the context menu.

You cannot use this account to purchase a commercial plan on Developer Portal, as it is already associated to plans with different payment methods.

To purchase a commercial plan on Developer Portal, please register for or sign in with a different HERE Account.

Something took longer than expected.

The project should be available soon under your projects page.

Sorry, our services are not available in this region.

Something seems to have gone wrong. Please try again later.

We've detected that your account is set to Australian Dollars (AUD).
Unfortunately, we do not offer checkouts in AUD anymore.
You can continue using your current plan as normal, but to subscribe to one of our new plans,
please register for a new HERE account or contact us for billing questions on selfservesupport@here.com.