Documentation menu
Example
Turn instructions anchored to landmarks
"Turn right just after the Shell garage", beside the engine's own street-name instruction rather than instead of it. Nothing is named unless it is recognisable from the road, within 40 m of the junction and not tagged as closed, so many routes come back with none.
ts
import { buildRouteUrl, parseOsrmRoute } from "@mapmap/maps";
// buildRouteUrl already asks for steps=true and geometries=geojson; append
// the landmarks flag. It deliberately does NOT embed the API key, so add
// the Authorization header yourself.
const url =
buildRouteUrl("https://api.mapmap.ai", "driving", [
{ lng: -0.1278, lat: 51.5074 },
{ lng: -0.1410, lat: 51.5155 },
]) + "&landmarks=true";
const body = await (
await fetch(url, { headers: { Authorization: "Bearer snk_..." } })
).json();
const parsed = parseOsrmRoute(body);
console.log(parsed.distanceM, parsed.durationS);
// Read landmark_instruction aloud where it is present; it is the one a
// passenger would have given you. Absent, fall back to the street name.
for (const step of body.routes[0].legs[0].steps) {
console.log(step.landmark_instruction ?? step.name);
}