TMaps API examples / 03

Vector map styles with MapLibre GL

TMaps vector tiles rendered by MapLibre GL JS: sharp on every screen, smooth zoom and rotation. Four styles are available and can be switched without reloading the map.

Style
Style URL
https://tiles.tmaps.tn/v-tile/streets.json?api_key=YOUR_API_KEY

How it works

  1. Each style is a JSON file following the Mapbox Style Specification: https://tiles.tmaps.tn/v-tile/{style}.json.
  2. MapLibre reads the tile sources, fonts and icons from that file. You don't call the .pbf tiles yourself.
  3. map.setStyle(url) switches the style without destroying the map, which makes a dark mode toggle easy.

Available styles

  • streets: light reference map, built for reading streets and points of interest.
  • dark: dark variant for dashboards and night mode.
  • terrain: highlights relief, rivers and topography.
  • sunny: warm palette for tourism and retail.

The code

const map = new maplibregl.Map({
  container: 'map',
  style: 'https://tiles.tmaps.tn/v-tile/streets.json?api_key=YOUR_API_KEY',
  center: [10.1815, 36.8002],
  zoom: 12,
});

Vector tiles docs · Source on GitHub