Get started with Leaflet

This Quickstart Leaflet example is the easiest and fastest way to use your MapTiler maps in Leaflet JS. Simply use the code below the map.

  1. Copy the following code, paste it into your favorite text editor, and save it as a .html file.

  1. Install the npm package.

  2. Include the CSS file.

    If you have a bundler that can handle CSS, you can import the CSS or include it with a <link> in the head of the document via the CDN

  3. Include the following code in your JavaScript file (Example: main.js).

  1. Replace YOUR_MAPTILER_API_KEY_HERE with your own API key. Make sure to secure the key before you publish it.

  2. The next is up to you. You can center your map wherever you desire (modifying the starting position) and set an appropriate zoom level (modifying the starting zoom) to match your users’ needs. Additionally, you can change the map’s look (by updating the source URL); choose from a range of visually appealing map styles from our extensive MapTiler standard maps, or create your own to truly differentiate your application.

Learn more

If you want to learn how to initialize a map and load the style see the How to use Leaflet JS tutorial.

How to use Leaflet

How to use Leaflet

Tutorials

Create and display Leaflet maps on web pages with MapTiler.

Display a Marker on the map using Leaflet

Display Marker

Tutorials

Add default map markers using Leaflet JS web mapping library.

Use Leaflet JS with Vector Tiles

Vector Tiles in Leaflet

Tutorials

Display MapTiler vector tiles in Leaflet using maptilersdk plugin.

Was this helpful?