TMaps API examples / 07

Directions with turn-by-turn instructions

Drag the A and B markers to calculate a route in Tunisia. The TMaps Directions API returns the distance, the travel time, the route geometry and turn-by-turn instructions.

Drag the markers, or click the map to move B.

API request
GET https://api.tmaps.tn/routing/direction?from=36.7992,10.1709&to=36.8528,10.3261&profile=driving&geometry=geojson&steps=true&api_key=YOUR_API_KEY

How it works

  1. The page sends GET /routing/direction with from and to as lat,lng.
  2. geometry=geojson returns the route as a GeoJSON LineString that Leaflet draws directly, with no polyline decoder.
  3. steps=true adds the turn-by-turn instructions in legs[].steps, in the language set by language.

Good to know

  • Profiles: driving, walking, cycling and truck (avoids roads closed to heavy vehicles).
  • For more than two points, send a POST with a waypoints array (up to 25).
  • avoid accepts tolls, highways, ferries and unpaved. departure_time or arrival_time (local time, e.g. 2026-12-01T08:30) give the times of a trip at a given hour. alternatives=true returns up to two other routes.
  • Distances are in meters and durations in seconds.

Directions docs · Source on GitHub