TMaps API examples / 01

Map of Tunisia with Leaflet

The simplest way to show a TMaps map: Leaflet plus the TMaps raster tiles. Worldwide coverage, with extra detail for Tunisia.

Tile URL
https://tiles.tmaps.tn/r-tile/{z}/{x}/{y}?api_key=YOUR_API_KEY

How it works

  1. Leaflet requests 256 × 256 PNG tiles following the standard XYZ scheme (z = zoom, x/y = tile position).
  2. The API key is passed in the api_key query parameter of the tile URL.
  3. Set maxZoom: 18: tiles stop at zoom 18.

The code

const map = L.map('map').setView([36.8002, 10.1815], 12);

L.tileLayer(
  'https://tiles.tmaps.tn/r-tile/{z}/{x}/{y}?api_key=YOUR_API_KEY',
  { maxZoom: 18, attribution: '© TMaps' }
).addTo(map);

Good to know

  • The same tile URL works in OpenLayers, MapLibre GL and mobile SDKs that support XYZ layers.
  • Tiles are sent with long cache headers. Enable disk caching on mobile to save data.
  • Retina (@2x) tiles are not available yet. For sharp maps on high-density screens, use the vector tiles.

Raster tiles docs · Source on GitHub