Article

Loading the Latest or a Specific Version of MapKit JS

Link to the most recent version of MapKit JS or a version of your choice.

Overview

MapKit JS follows semantic versioning with each release. This means that you as the developer have full control over when to upgrade to a new version of MapKit JS. Each version follows the standard semantic versioning pattern MAJOR.MINOR.PATCH, which conveys the following information:

  • MAJOR: Incompatible API changes

  • MINOR: New functionality, but backward-compatible

  • PATCH: Backward-compatible bug fixes

In other words, a backward-compatible new release that contains only bug fixes increases the patch version; a backward-compatible new release that contains new features or functionality increases the minor version. And a new release that changes the API so it is no longer backward-compatible increases the major version.

Add a Script Tag

You can link to MapKit JS by adding a script tag to your web page, as shown here:

<script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script>

The value of the src attribute of this script tag will be a URL that points to mapkit.js, the principal JavaScript file for MapKit JS. There are two types of URLs available for mapkit.js:

  • URLs that return a specific version

  • URLs that return the latest available version for the specified MAJOR and MINOR version

Link to a Specific Version of MapKit JS

Each version of MapKit JS has a unique URL. You can link to a version to guarantee that your web page will always use the version of MapKit JS specified. Here are a few examples of script tags that link to a specific version:

<script src="https://cdn.apple-mapkit.com/mk/5.20.0/mapkit.js"></script>
<script src="https://cdn.apple-mapkit.com/mk/5.23.1/mapkit.js"></script>

Link to the Latest Available Version of MapKit JS

To always link to the latest available version of MapKit JS, use a URL in your script tag that specifies "x" for the MINOR and PATCH fields of the version number. Using "x" ensures your web page receives the latest backward-compatible features and bug fixes without having to change the mapkit.js URL in your code.

For example, linking to version 5.1.x means that the MAJOR.MINOR version is pinned at 5.1, and the server automatically returns the latest PATCH version of mapkit.js.

<script src="https://cdn.apple-mapkit.com/mk/5.1.x/mapkit.js"></script>

Linking to version 5.x.x means that the MAJOR version is pinned at 5, and the server automatically returns the latest MINOR.PATCH version. Linking to the latest major version of mapkit.js by using version number 5.x.x is recommended.

<script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script>

After linking to MapKit JS, you initialize mapkit with init, then add a map to your web page with mapkit.Map.

See Also

MapKit JS

Creating a Maps Identifier and a Private Key

Create a Maps Identifer and a private key before generating tokens for MapKit JS.

Creating and Using Tokens with MapKit JS

Learn how to create JSON Web Tokens to use with MapKit JS.

MapKit JS Release Notes

Learn about updates, bug fixes, and API changes for MapKit JS.

mapkit

The JavaScript API for embedding Apple maps on your website.