How to use MapLibre GL JS

This tutorial shows how to create a MapLibre GL JS map and display it on a web page using MapTiler. For a better developer experience and easier integration with MapTiler maps and API services, it is best to use the MapTiler SDK JS. MapTiler SDK JS is an extension of MapLibre.

The SDK includes many modules with pre-built functions, so you can quickly implement search and other geocoding features, display 3D models on maps, build weather applications, and more. Check out all modules.

NPM module setup


npm install --save maplibre-gl
import { Map } from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';

const key = 'YOUR_MAPTILER_API_KEY_HERE';
  
const map = new Map({
  container: 'map', // container id
  style: `https://api.maptiler.com/maps/streets-v4/style.json?key=${key}`, // style URL
  center: [0, 0], // starting position [lng, lat]
  zoom: 1 // starting zoom
});

Learn more

Check out the How to migrate/switch from MapLibre to MapTiler tutorial.

Was this helpful?