TMaps API examples / 05

Address from a map click (reverse geocoding)

Click anywhere on the map. The TMaps Reverse Geocoding API turns the GPS coordinates into a postal address with its commune, delegation and governorate.

Click the map to look up an address.

API request
GET https://api.tmaps.tn/geocoding/reverse?lat=36.8002&lng=10.1815&lang=fr&api_key=YOUR_API_KEY

How it works

  1. A click on the map gives a latitude and longitude.
  2. The page sends GET /geocoding/reverse with lat, lng and lang.
  3. The API snaps to the nearest relevant street or building and returns its address, with the point in geometry.location. distance tells you how far it is, in meters, from the clicked point.

Good to know

  • Use type=locality when you only need the commune, for example to tag a GPS log.
  • A 404 means no address was found near the point (sea, desert).
  • Typical uses: showing the address of the user's GPS position, enriching field inspection points, labelling raw coordinates in logs.

Reverse Geocoding docs · Source on GitHub