Initialize MapKit JS by providing an authorization callback function and optional language.
- MapKit JS 5.0+
MapKit JS initialization options.
Once you have created a JWT according to the guidelines in Creating and Using Tokens with MapKit JS, you are ready to begin using MapKit JS. The first step is to initialize the
mapkit object with a token. To do this, set
authorization to a function that obtains a token and passes it to the
If you have created a server endpoint to deliver new tokens to MapKit JS, make an asynchronous request to this endpoint in your
authorization function and call
done() with the result.
If you haven't set up a server endpoint, you can alternately set
authorization to a function that simply provides a pre-generated token string.
It is safe to call
mapkit before the content of your page has fully loaded; in other words, before the
window event fires. A
mapkit object dispatches a
configuration-change event once it has been initialized, and an
error event when initialization fails. You can learn more about both of these events in Handling Initialization Events.