Skip to content

Repository files navigation

TMaps API Examples | Maps, Geocoding & Routing for Tunisia

Ready-to-run, client-side code examples for the TMaps APIs: map tiles, geocoding, routing, isochrones, distance matrix and static maps. Each example is one HTML page with no build step, using Leaflet, OpenLayers or MapLibre GL, and shows the exact API request it sends.

🇫🇷 Exemples de code prêts à l'emploi pour les API TMaps : cartes, géocodage, itinéraires et isochrones en Tunisie. Chaque exemple est une page HTML sans build qui affiche la requête API envoyée.

▶ Browse all live demos · API documentation

Examples

# Example API Library Demo
01 Map with Leaflet Raster tiles Leaflet Live
02 Map with OpenLayers Raster tiles OpenLayers Live
03 Vector map styles Vector tiles MapLibre GL Live
04 Address search Forward geocoding Leaflet Live
05 Address from a map click Reverse geocoding Leaflet Live
08 Nearby places Nearby search Leaflet Live
12 Checkout address form Forward + reverse geocoding Leaflet Live

Coming soon: static map, directions, isochrone, optimized route and distance matrix examples (pending/).

Postman collection

Run in Postman

Try the API without writing code: fork the collection from the TMaps public workspace or import the files in postman/ (tiles, forward and reverse geocoding, nearby search), set your key and send. Each request comes with documented parameters, example responses and tests.

CodePen and JSFiddle

Prefer to play in the browser? Four examples are on CodePen and JSFiddle, ready to fork: a Leaflet map, vector styles with MapLibre, an OpenLayers map with a shareable view and an address search in French, Arabic and Arabizi. The same examples on JSFiddle: Leaflet, MapLibre, OpenLayers and address search. Their code is in playgrounds/.

Repository layout

demos/            Client-side examples (plain HTML, no build), published on GitHub Pages
servers/go/       Go server (standard library only)
servers/node/     Node.js server (no dependencies)
servers/python/   Python server (standard library only)
postman/          Postman collection and environment
playgrounds/      Code of the CodePen and JSFiddle examples (HTML, CSS, JS panels)
pending/          Examples waiting for their API endpoint in production
docker-compose.yml

The three servers do the same thing: serve demos/ and generate /shared/config.js from the TMAPS_API_KEY environment variable, so your key never has to be committed. Pick the one that matches your stack.

Run locally

Get an API key from the TMaps console and add localhost to its authorized domains.

With Docker Compose (all three servers)

cp .env.example .env   # then put your key in .env
docker compose up --build
Server URL
Go http://localhost:8081
Node.js http://localhost:8082
Python http://localhost:8083

Without Docker

# Go 1.22+
cd servers/go && TMAPS_API_KEY=your_key go run .

# Node.js 20+
cd servers/node && TMAPS_API_KEY=your_key node server.js

# Python 3.8+
cd servers/python && TMAPS_API_KEY=your_key python3 server.py

Each server listens on http://localhost:8080 (change it with PORT).

Single image

docker build -f servers/go/Dockerfile -t tmaps-snippets .
docker run --rm -p 8080:8080 -e TMAPS_API_KEY=your_key tmaps-snippets

GitHub Pages

The Pages workflow publishes demos/ on every push to main. Add your test key as a repository secret named TMAPS_API_KEY and it is injected into shared/config.js at deploy time.

About API keys in client-side code

A key used in the browser is always visible in the page source. Protect it by restricting it to your own domains in the TMaps console: requests from any other origin are rejected with 403. See Authentication.

License

MIT © MapWay

Releases

Packages

Contributors

Languages