Skip to main content

Published on 25 November 2026

Integrating swisstopo Vector Tiles with External APIs

This tutorial is intended for web developers and advanced users who are familiar with JavaScript, MapLibre GL JS and basic web mapping concepts. You should understand how vector tiles and map styles work. Previous experience with APIs is helpful, but the relevant concepts will be explained throughout this tutorial.

Introduction

Vector tiles provide a flexible way to display geographic information on interactive maps. In this tutorial, we will use MapLibre GL JS together with the swisstopo vector tile basemap to build an interactive map of public transport stops in Switzerland.

By accessing information embedded in the vector tiles and combining it with an external API, we can turn a standard basemap into an interactive application. When users click on a public transport icon, the map retrieves and displays the next scheduled departures for that stop using the Swiss Transport API.
The tutorial will guide you through the process step by step, starting with a basic swisstopo basemap and gradually adding the functionality needed to identify transport stops, retrieve departure information and display it in a popup. By the end, you will have learned how to:

  • Display a swisstopo vector tile basemap using MapLibre GL JS.
  • Identify public transport points of interest (POIs) in the vector tiles.
  • Access attributes stored in vector tile features.
  • Retrieve public transport departure information from an external API.
  • Display the retrieved information in an interactive map popup.
  • Highlight the selected transport stop on the map.

Try the interactive map

Click on any public transport icon to see the next departures for that stop.

See code example on JSFIddle

References and further reading

More tutorials