This is the documentation of version 1.0.0-rc.4. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias CalculateRouteParams

    CalculateRouteParams: CommonServiceParams<
        CalculateRouteRequestAPI,
        CalculateRouteResponseAPI,
    > & CommonRoutingParams & {
        arrivalSide?: ArrivalSide;
        computeTravelTimeFor?: ComputeTravelTimeFor;
        curveDetection?: CurveDetectionOptions;
        extendedRouteRepresentations?: ExtendedRouteRepresentation[];
        guidance?: GuidanceParams;
        locations: RoutePlanningLocation[];
        maxAlternatives?: MaxNumberOfAlternatives;
        sectionTypes?: InputSectionTypes;
        useEntryPoints?: GetPositionEntryPointOption;
    }

    Parameters for calculating a route between waypoints.

    They include the origin, destination, optional intermediate waypoints and routing options that customize the calculated route by vehicle type, traffic and preferences.

    Type Declaration

    • OptionalarrivalSide?: ArrivalSide

      Which side of the road the route should arrive on.

      • any: arrive from either side, whichever is faster
      • curb: arrive on the curb side for the country's driving direction, so passengers or deliveries can leave the vehicle without crossing the road

      Applies to the destination and to every intermediate stop.

      'any'
      
      // Pull up on the passenger side at each stop
      arrivalSide: 'curb'
    • OptionalcomputeTravelTimeFor?: ComputeTravelTimeFor

      Travel time calculations for different traffic scenarios.

      When set to 'all', the returned route summary contains extra fields:

      • noTrafficTravelTimeInSeconds – Free-flow (no traffic)
      • historicTrafficTravelTimeInSeconds – Historic traffic patterns
      • liveTrafficIncidentsTravelTimeInSeconds – Current live traffic

      Use them to compare traffic impact and display "X minutes saved by leaving now".

      'none'
      
      computeTravelTimeFor: 'all'
      
    • OptionalcurveDetection?: CurveDetectionOptions

      The thresholds the SDK finds the curve and curvyStretch sections with, when sectionTypes names them.

      The SDK finds them in the route's geometry once it comes back, so they change nothing the routing API returns. To find them again with other thresholds, with no new request, pass the route to core's withCurveSections.

      The defaults of core's getCurveSections and getCurvyStretchSections.

      // Only the hard curves, and the stretches of five or more of them
      curveDetection: { curve: { maxRadiusInMeters: 100 }, curvyStretch: { minCurveCount: 5 } }
    • OptionalextendedRouteRepresentations?: ExtendedRouteRepresentation[]

      Extended progress information at route polyline points.

      When non-empty, the route features contain an extra "progress" property, an array of objects containing:

      • pointIndex – Index of the coordinate in the route geometry
      • travelTimeInSeconds - Cumulative travel time from start to this point
      • distanceInMeters - Cumulative distance from start to this point

      Use it to display progress during navigation or to animate route visualization.

      Progress points are all-or-nothing, as ExtendedRouteRepresentation explains: pass an empty array to opt out.

      ['distance', 'travelTime']
      
      extendedRouteRepresentations: ['distance', 'travelTime']

      // Opt out of progress points altogether
      extendedRouteRepresentations: []
    • Optionalguidance?: GuidanceParams

      Turn-by-turn guidance instructions to request.

      When specified, the response includes detailed instructions with maneuvers and road names.

      guidance: { type: 'coded' }
      
    • locations: RoutePlanningLocation[]

      Ordered list of locations (waypoints) and/or path points for route calculation.

      The route passes through these locations in the specified order.

      It needs at least 2 waypoints (origin and destination), or 1 path with 2+ points.

      Supported formats:

      • Coordinate arrays: [longitude, latitude]
      • Path arrays for route reconstruction
      • Waypoint Features, whose properties carry the per-stop options

      The route ends a leg at every location in this list. There is no circle (soft) waypoint that the route merely passes, because the routing API takes a plain point for each one. A path pins the geometry the route must follow, but its endpoints go out as waypoints as well, so it shapes the route without shortening the list of legs.

      // Coordinate arrays
      locations: [[4.9, 52.3], [4.5, 51.9]]

      // With intermediate stop
      locations: [[4.9, 52.3], [4.7, 52.1], [4.5, 51.9]]

      // Path array for route reconstruction
      locations: [
      [4.9, 52.3], // Origin waypoint
      [
      [4.85, 52.25], [4.80, 52.20], [4.75, 52.15] // Path points between waypoints
      ],
      [4.5, 51.9] // Destination waypoint
      ]
    • OptionalmaxAlternatives?: MaxNumberOfAlternatives

      Maximum number of alternative routes to calculate.

      Alternative routes provide different travel options between the same origin and destination. Each alternative is optimized differently (e.g., avoiding highways, minimizing tolls).

      More alternatives increase response time. Alternatives are returned in order of quality, best first. Not all requests return the maximum number of alternatives.

      0
      
      // Request up to 2 alternatives
      maxAlternatives: 2
    • OptionalsectionTypes?: InputSectionTypes

      Route section types to include in the response.

      Sections help you display route characteristics like tolls, ferries, or traffic. Leg sections are always included regardless of this parameter, and so are distinct sections when two or more routes come back. A section type is only present in the response if the route actually traverses it. The lanes section is returned only when guidance is also requested, and, when a list is given, only if it includes lanes. The SDK finds curve and curvyStretch in the route's geometry, with the thresholds of curveDetection, and only when the list names them.

      When omitted, core's defaultSectionTypes: every type but curve and curvyStretch.

      // Request specific sections (any combination of available section types)
      sectionTypes: ['toll', 'ferry', 'traffic', 'country', 'roadShields']

      // The default sections, and the curves
      sectionTypes: [...defaultSectionTypes, 'curve', 'curvyStretch']

      // Request no optional sections
      sectionTypes: []
    • OptionaluseEntryPoints?: GetPositionEntryPointOption

      How entry points are used for routing.

      Entry points represent specific building entrances or facility access points. They improve routing accuracy by directing to the correct entrance.

      • main-when-available: Use the entry point GetPositionEntryPointOption picks, otherwise the place center (recommended for routing)
      • ignore: Always use place center position
      'ignore' (a place's geometry is used)
      
      // Route to main entrance when available
      useEntryPoints: 'main-when-available'
    // Basic route from A to B
    const params: CalculateRouteParams = {
    apiKey: 'your-api-key',
    locations: [
    [4.9041, 52.3676], // Amsterdam
    [4.4777, 51.9244] // Rotterdam
    ]
    };

    // Route with guidance and alternatives
    const advancedParams: CalculateRouteParams = {
    apiKey: 'your-api-key',
    locations: [[4.9041, 52.3676], [4.4777, 51.9244]],
    guidance: { type: 'coded' },
    maxAlternatives: 2,
    costModel: {
    routeType: 'fast',
    avoid: ['tollRoads', 'motorways']
    },
    when: {
    option: 'departAt',
    localDateTime: '2026-10-19T08:00:00'
    }
    };

    // Route for a speed-limited truck
    const truckParams: CalculateRouteParams = {
    apiKey: 'your-api-key',
    locations: [[4.9, 52.3], [8.5, 50.1]],
    vehicle: {
    model: { dimensions: { weightKG: 40000 } },
    restrictions: { maxSpeedKMH: 80 }
    }
    };