Guidance
guidance adds turn-by-turn instructions to each route: maneuvers, ready-made instruction text,
road names, road shields and junction layouts.
Basic usage
'coded' is the only instruction format:
import { calculateRoute } from '@tomtom-org/maps-sdk/services';
const routes = await calculateRoute({
locations: [[4.9041, 52.3676], [2.3522, 48.8566]],
guidance: { type: 'coded' }
});
const instructions = routes.features[0].properties.guidance?.instructions;
- Requesting guidance also returns lane guidance in the
lanessection, unless asectionTypeslist leaveslanesout. No request returnslaneswithout guidance. - On the map,
RoutingModuledraws the instructions as arrows. See Displaying guidance on map.
What each instruction carries
message– The ready-made instruction text, for example'Turn right onto Damrak'. The service generates and localises it in the request's language, so a turn list needs no translation table.maneuver– The maneuver code, for example'TURN_RIGHT'.maneuverPoint/pathPointIndex– Where the maneuver happens, as a[longitude, latitude]position and its index into the route'sgeometry.coordinates. The point is the junction as the router names it, so it can sit a few metres off the sampled path.routeOffsetInMeters– Distance from the start of the route to the maneuver.maneuverView– The junction layout.onRouteAngleis the direction the route takes, andoffRouteAnglesare the ones it passes up. Both are relative directions ('STRAIGHT','SLIGHT_RIGHT','BACK', …), not degrees, but enough to draw a junction diagram.roundaboutType–'REGULAR'or'SMALL', on roundabout maneuvers.sideRoads– Roads joining the route near the maneuver, each with itsside('LEFT' | 'RIGHT' | 'LEFT_AND_RIGHT'),offsetFromManeuverInMetersandisDrivable.- A non-drivable side road can't be taken by mistake, but it still belongs in a junction diagram.
nextRoadInfo/previousRoadInfo– The road after and before the maneuver, withstreetName,roadShieldsand an ISO 3166-1 alpha-3countryCode.signpost,tollgateName,countryCrossingFromName/countryCrossingToName– Present on the maneuvers they apply to.
Name fields (street names, road numbers, signpost exits, intersections, tollgates and countries) are
InstructionText objects, carrying the name as text:
instructions?.forEach((instruction) => {
console.log(instruction.message, instruction.nextRoadInfo.streetName?.text);
});
Road shield references
Road shield images come from the TomTom Road Shield API. Each instruction carries
roadShieldReferences for the instruction and signpostRoadShieldReferences for its signpost.
roadShieldAtlasReference is the base URL they resolve against.
API reference
- GuidanceParams – The request parameter
- Instruction – Every field of an instruction
Related guides and examples
Related guides
- Routing quickstart – Getting started with route calculation
- Route planning parameters – Every other option
- Route object – Where guidance sits in the response
Related examples
- Route with guidance – A route with its guidance arrows