Route planning parameters
Route planning involves configuring parameters to calculate optimal routes between locations. This guide covers all available options for customizing route calculation.
Locations
For comprehensive guide on specifying route planning locations, see Locations.
Ordered list of locations for route calculation. Locations can be specified as single point waypoints or path arrays.
Calculate a route between two locations:
import { calculateRoute } from '@tomtom-org/maps-sdk/services';
const route = await calculateRoute({ locations: [ [4.9041, 52.3676], // Amsterdam coordinates [2.3522, 48.8566] // Paris coordinates ]});Calculate a route following a specific path using path arrays:
const route = await calculateRoute({ locations: [ [4.9, 52.3], // Origin waypoint [ [4.85, 52.25], // Path points [4.80, 52.20], [4.75, 52.15] ], [4.5, 51.9] // Destination waypoint ]});Calculate a route between two geocoded locations:
import { geocodeOne } from '@tomtom-org/maps-sdk/services';
const waypoints = await Promise.all([ geocodeOne('Amsterdam, Netherlands'), geocodeOne('Paris, France')]);
const route = await calculateRoute({ locations: waypoints });Alternative routes
Request multiple route options with maxAlternatives.
Alternative routes provide different travel options between the same origin and destination. Each alternative is optimized differently (e.g., avoiding highways, minimizing tolls). The best route is always returned as the first option.
Note: May return fewer alternatives than requested if not enough viable routes found.
Note: Increasing alternatives amount also increases response time.
const routes = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]],
// Returns up to 3 routes total (best + 2 alternatives) maxAlternatives: 2});Cost model
Configure route type, traffic consideration, and avoidances using costModel.
routeType – Type of route optimization
fast- Optimized by travel time (default)short- Optimized by travel distanceefficient- Balance between time and fuel/energy consumptionthrilling- Scenic routes with fewer motorways (max 900km)
traffic – What traffic data to consider for route planning
live- Real-time traffic + historical patterns (default)historical- Typical traffic patterns only
avoid – Route features to try to avoid (none by default)
tollRoads– roads requiring toll paymentsmotorways– high-speed limited-access highways (useful for scenic routes or vehicle restrictions)ferries– water crossings requiring ferry transportunpavedRoads– unpaved/dirt roads (recommended for standard vehicles)carpools– carpool/HOV (High Occupancy Vehicle) lanesalreadyUsedRoads– prevents using the same road segment multiple times (useful for delivery routes)borderCrossings– crossing international borders (useful for customs/visa considerations)tunnels– underground tunnels (useful for vehicles carrying hazardous materials)carTrains– car train transport segmentslowEmissionZones– zones with vehicle emission restrictions
avoidAreas – Rectangular geographic areas for the routing engine to bypass, expressed as GeoJSON bounding boxes [west, south, east, north] (up to 10)
- Each rectangle is limited to ~160×160 km
- Cannot cross the 180th meridian
- Latitude must be between −80° and +80°
// Fast route considering live trafficconst route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], costModel: { routeType: 'fast', // default traffic: 'live' // default }});
// Short route avoiding tollsconst route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], costModel: { routeType: 'short', avoid: ['tollRoads'] }});
// Efficient route avoiding highways and ferriesconst route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], costModel: { routeType: 'efficient', traffic: 'historical', avoid: ['motorways', 'ferries'] }});
// Route bypassing a specific geographic area (e.g., a construction zone)const route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], costModel: { avoidAreas: [ [2.265938, 48.81851, 2.41115, 48.90309] // [west, south, east, north] ] }});Departure and arrival time
Control when to depart or arrive using when.
The response will contain estimated departure and arrival times based on the provided parameters at summary.departureTime and summary.arrivalTime.
// Depart at specific timeconst route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], when: { option: 'departAt', date: new Date('2025-12-25T09:00:00Z') }});
// Arrive by specific timeconst route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], when: { option: 'arriveBy', date: new Date('2025-12-25T17:00:00Z') }});Vehicle configuration
For comprehensive guide on specifying vehicle configuration, see Vehicle Configuration.
Configure vehicle-specific routing with the vehicle parameter.
model – vehicle dimensions and engine details
state – current vehicle state (fuel/charge levels)
restrictions – cargo and usage restrictions
preferences – charging preferences (electric vehicles only)
// Generic vehicleconst route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], vehicle: { model: { dimensions: { weightKG: 3500 } } }});Turn-by-turn guidance
For comprehensive guide on navigation guidance, see Guidance.
Request navigation instructions:
const route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], guidance: { type: 'coded', version: 2, phonetics: 'IPA' }});Route sections
Request specific section to be included in the route response. Leg sections are always included.
Route section types:
carpool, carTrain, country, ferry, importantRoadStretch, lanes, leg, lowEmissionZone, motorway, pedestrian, roadShields, speedLimit, toll, tollVignette, traffic, tunnel, unpaved, urban, vehicleRestricted,
Includes all available section types by default.
const route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], sectionTypes: ['toll', 'ferry', 'traffic', 'motorway', 'country']});See the full list of available section types in the Route Object Guide.
Extended route information
Include progress data at route polyline points (enabled by default). The resulting route object will contain an additional property “progress” containing arrays of cumulative values for each point of the route.
Useful for displaying progress during navigation.
const route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], extendedRouteRepresentations: ['distance', 'travelTime'] // default});Traffic-based travel times
Compare travel times across different traffic scenarios.
none – only current traffic travel time is returned (default)
all – the returned route summary will contain extra fields:
noTrafficTravelTimeInSeconds– Free-flow (no traffic)historicTrafficTravelTimeInSeconds– Historic traffic patternsliveTrafficIncidentsTravelTimeInSeconds– Current live traffic
Useful for comparing traffic impact and displaying “X minutes saved by leaving now”.
const route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], computeTravelTimeFor: 'all'});Per-stop options
Any waypoint can carry its own options in properties, typed with RouteStopOptions. They
describe the leg arriving at that stop plus the wait once there, so inserting an earlier stop
later on leaves them attached to the right place.
-
pauseDurationSeconds– how long the vehicle waits at this stop. Counted into the route’s journey time, not only the arrival time. Not supported on the destination. This one is a standard waypoint property, soRoutingModule.showWaypointslabels the stop’s pin with it.It comes back on the leg that arrives at the stop, as
stopTimeInSeconds:const legs = route.features[0].properties.sections.leg;legs[0].summary.stopTimeInSeconds; // time spent at the first stoplegs[0].summary.travelTimeInSeconds; // driving only, the stop is not in herestopTimeInSecondsis one number for the whole stop, whatever it is spent on — the wait you asked for, charging the service planned on an EV route, or both at one stop. For the breakdown,chargingInformationAtEndOfLegcarries the charging part and whatever is left is waiting.A leg’s
travelTimeInSecondsis driving only, while the route’s total includes every stop — so driving time is the sum of the legs, and the time standing still is the difference. -
legCostModel–routeTypeandavoidfor the arriving leg only, falling back to the route-wide cost model. Ignored on the origin, which has no arriving leg. -
candidateEntryPoints– approach points to offer the routing engine, with an optionalpreferredEntryPointIndex. Takes precedence overuseEntryPointsfor this stop.
const route = await calculateRoute({ locations: [ [2.1734, 41.3851], { type: 'Feature', geometry: { type: 'Point', coordinates: [2.4467, 41.5381] }, properties: { pauseDurationSeconds: 1800, legCostModel: { routeType: 'short', avoid: ['motorways'] } } }, [2.8214, 41.9794] ]});Arrival side
Which side of the road to arrive on, at the destination and at every intermediate stop:
any – arrive from either side, whichever is faster (default)
curb – arrive on the curb side for the country’s driving direction
const route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], arrivalSide: 'curb'});Entry points
Control how building entry points are used:
main-when-available – routes to main entrance when available (default)
ignore – use place center position
const route = await calculateRoute({ locations: [[4.9041, 52.3676], [2.3522, 48.8566]], useEntryPoints: 'ignore'});For a stop with several usable entrances, candidateEntryPoints above hands the alternatives to
the routing engine instead of resolving one position client-side.
API reference
For complete documentation of all route calculation parameters and types, see the CalculateRouteParams API Reference.
Related guides and examples
Related guides
- Route Object - Understanding route structure
- Routing Quickstart - Getting started with route calculation
- Locations - Specifying route planning locations
- Guidance - Navigation instructions
- Vehicle Configuration - In-depth vehicle configuration
Related examples
- Route stop wait playground - Adjust the wait at a stop and watch the journey time
- Route leg options playground - Give each leg its own route type and avoid list
Map integration
- Routing Module - Display calculated routes on map