Handling initialization events
Respond to events that trigger when MapKit JS initializes.
Overview
Unless you wish to explicitly control initialization timing in JavaScript, use data-token instead of handling initialization events directly. See Loading the latest version of MapKit JS for more information.
The mapkit object emits two events to indicate the success or failure of a configuration operation. The initialization process configures MapKit JS. In addition, there are two events indicate the success or failure of a batch of library loads.
Event | Interface | Summary |
|---|---|---|
| The MapKit configuration changes due to either a successful initialization or a refresh. | |
| MapKit fails to initialize. | |
| A batch of libraries loads. | |
| A batch of libraries fails to load. |
MapKit JS invokes these events asynchronously upon success or failure of the initialization request. The example below shows a common use case:
mapkit.init({ authorizationCallback: function(done) { done("your-token"); }, ... });
mapkit.addEventListener("configuration-change", function(event) {
switch (event.status) {
case "Initialized":
// MapKit JS initializes and configures.
break;
case "Refreshed":
// The MapKit JS configuration updates.
break;
}
});