Article

Handling Initialization Events

Handle events that trigger when MapKit JS initializes.

Overview

The mapkit object emits two events to indicate the success or failure of a configuration operation. MapKit is configured when it initializes.

Event

Summary

configuration-change

MapKit configuration changed due to either a successful initialization or a refresh. The event has the property status (String), which indicates the configuration change status.

Initialized: MapKit successfully initialized and configured.

Refreshed: MapKit configuration updated.

error

MapKit failed to initialize. The event has the property status (String), which indicates the status response.

Unauthorized: The authorization token provided is invalid.

Too Many Requests: The authorization token provided is based on a Maps ID, which has exceeded its allowed daily usage.

MapKit JS will envoke these events asyncrounously upon success or failure of the initialization request. A common use-case is shown in the following example:

mapkit.init({ authorizationCallback: function(done) { done("your-token"); }, ... });
mapkit.addEventListener("configuration-change", function(event) {
    switch (event.status) {
    case "Initialized":
        // MapKit JS initialized and configured.
        break;
    case "Refreshed":
        // MapKit JS configuration updated.
        break;
    }
});

See Also

Initialization

init

Initialize MapKit JS by providing an authorization callback function and optional language.

MapKitInitOptions

Initialization options for MapKit JS.

addEventListener

Subscribes a listener function to an event type.

removeEventListener

Unsubscribes a listener function from an event type.