Display Vector Tiles in MapLibre GL JS
Basic Map
A full-page map using the terrain style:
const map = new maplibregl.Map({
container: 'map',
style: 'https://styles.maptoolkit.net/maptoolkit/maptoolkit.summer.json?api_key=YOUR_API_KEY',
center: [12.805988, 47.310897],
zoom: 11
});<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.jsdelivr.net/npm/maplibre-gl@5.6.1/dist/maplibre-gl.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/maplibre-gl@5.6.1/dist/maplibre-gl.css" />
<style>
html, body { width: 100%; height: 100%; margin: 0; padding: 0; }
#map { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id="map" class="map"></div>
<script>
const map = new maplibregl.Map({
container: 'map',
style: 'https://styles.maptoolkit.net/maptoolkit/maptoolkit.summer.json?api_key=YOUR_API_KEY',
center: [12.805988, 47.310897],
zoom: 11
});
</script>
</body>
</html>Use the prompt below with any LLM to get the same result. Make sure the Maptoolkit MCP server is connected first — check out AI Integration & MCP to get started.
How it works
There is only one credential here, and no plugin. MapLibre GL JS reads Mapbox Style JSON
natively, and a Maptoolkit style URL is exactly that, so passing the URL to style is the
whole integration. The style names its own sources, so the library finds the tile server
without you configuring one.
The api_key travels in the style URL and is reused for the tile requests the style
triggers. Leave it out and the style itself returns 403, which surfaces as a blank map
rather than an error in most setups.
center is [longitude, latitude], the opposite order from Leaflet.
Next steps
You have a basemap, which is the starting point rather than the destination. The usual next
move is to put your own data on top of it: a GeoJSON source with a circle or line layer
for points and routes, or a symbol layer if the points need icons.
After that it is worth deciding which style you actually want. The seven listed in Vector Tiles differ in more than colour: Hiking and Winter carry four hillshade passes and read as mountains, Street is built for dense urban labelling. The style URL also takes a language suffix if your audience is not English-speaking.