This is the documentation of version 1.0.0-rc.2. 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;
        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'
      
    • OptionalextendedRouteRepresentations?: ExtendedRouteRepresentation[]

      Extended progress information at route polyline points.

      It includes cumulative distance and/or time from start to each coordinate. 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 (if "travelTime" is requested)
      • distanceInMeters - Cumulative distance from start to this point (if "distance" is requested)

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

      Orbis v3 has no per-representation selector, so progress points are all-or-nothing. Any non-empty array requests both distance and travelTime. To opt out entirely and keep the progress data out of the response payload, pass an empty array.

      ['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. 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.

      When omitted, all section types are requested.
      
      // Request specific sections (any combination of available section types)
      sectionTypes: ['toll', 'ferry', 'traffic', 'country', 'roadShields']

      // 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 main entry point if available, otherwise use 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',
    date: new Date('2025-10-20T08:00:00Z')
    }
    };

    // 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 }
    }
    };