Article

Handling Map Events

Handle events triggered by user interactions and the framework.

Overview

Use the Event type when adding and removing event listeners.

Map Display Events

Event

Summary

region-change-start

The map's visible region is about to change.

region-change-end

The map's visible region was changed.

scroll-start

The map is about to scroll as a result of user interaction.

scroll-end

The map was scrolled as a result of user interaction.

zoom-start

The map is about to zoom as a result of user interaction.

zoom-end

The map was zoomed as a result of user interaction.

map-type-change

The map's map type (mapkit.Map.MapTypes) was changed either programmatically or interactively by the user.

Annotation and Overlay Events

Event

Summary

select

An annotation or overlay was selected. The event will have one of these properties:

annotation (mapkit.Annotation): the annotation that was selected.

overlay (mapkit.Overlay): the overlay that was selected

deselect

An annotation or overlay was deselected. The event will have one of these properties:

annotation (mapkit.Annotation): the annotation that was deselected.

overlay (mapkit.Overlay): the overlay that was deselected

drag-start

An annotation is about to be dragged. The event has one property:

annotation (mapkit.Annotation): the annotation that is about to be dragged.

dragging

An annotation is being dragged. The event has two properties:

annotation (mapkit.Annotation): the annotation being dragged.

coordinate (mapkit.Coordinate): the current coordinate of the annotation. This is different from the annotation’s own coordinate property since that property is not updated until the annotation is dropped.

drag-end

An annotation was just dragged. The event has one property:

annotation (mapkit.Annotation): the annotation that was dragged.

User Location Events

Event

Summary

user-location-change

The user's location was acquired after showsUserLocation was set to true or after an automatic update. The event has these properties:

coordinate (mapkit.Coordinate): the current location.

timestamp (Date): the time at which the location was acquired.

user-location-error

MapKit JS was unable to acquire the user's location. The event has two properties:

code (Integer): A code indicating why location acquisition failed. Since this feature is implemented with HTML 5's geolocation API, the error codes mirror that API's error codes with one additional MapKit JS-specific error code:

Error.PERMISSION_DENIED (1) The user did not grant permission to obtain location information.

Error.POSITION_UNAVAILABLE (2) The geolocation API returned an error.

Error.TIMEOUT (3) The operation timed out without managing to acquire the location.

Error.MAPKIT_NOT_INITIALIZED (4) MapKit JS has not been initialized.

message (String): A human-readable string for the developer. This message is not intended for display to the end user.

See Also

Handling Map Events

addEventListener

Adds an event listener to handle events triggered by user interactions and the framework.

removeEventListener

Removes an event listener.