Powered by Zoomin Software. For more details please contactZoomin

HERE Maps API for JavaScript - API Reference

Product category
Technology
Doc type
Version
Product lifecycle
This publication

HERE Maps API for JavaScript - API Reference: Class: MapEvents

Table of Contents

Class: MapEvents

H.mapevents.MapEvents

new H.mapevents.MapEvents (map)

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

dispose () inherited overrides

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

contextmenu

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:

contextmenuclose

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:

dbltap

This event type signifies that the pointer (touch, pen) has touched the map (or object) surface twice in a row for a moment.

Type:

drag

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:

dragend

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 to true.

Type:

dragstart

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 to true.

Type:

longpress

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:

pointercancel

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:

pointerdown

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:

pointerenter

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:

pointerleave

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:

pointermove

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:

pointerup

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:

tap

This event type signifies that the pointer (touch, pen, mouse) has touched the map (or object) surface for a moment.

Type:
Was this article helpful?
TitleResults for “How to create a CRG?”Also Available inAlert