TMaps API examples / 12

Checkout address form

A delivery address form for a Tunisian e-commerce site. The customer types the start of the address, picks a suggestion, and the form fills in the commune, delegation and governorate. Dragging the pin refines the exact delivery point.

Please check the pin on the map: this address is not precise enough.

API request
GET https://api.tmaps.tn/geocoding/forward?q=…&country=TN&limit=5&api_key=YOUR_API_KEY

How it works

  1. While the customer types, GET /geocoding/forward returns up to 5 suggestions.
  2. Picking a suggestion fills the form from components and moves the pin to the address.
  3. Dragging the pin calls GET /geocoding/reverse to update the fields for the exact delivery point.
  4. On submit, the page shows the payload you would send to your backend: the address fields plus the GPS coordinates.

Good to know

  • Save coordinates directly only when confidence is at least 0.85. Below that, the form asks the customer to check the pin.
  • Storing the GPS point with the order saves drivers from calling the customer to find the address.
  • Set lang=ar to show addresses in Arabic.

Forward Geocoding docs · Reverse Geocoding docs · Source on GitHub