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.

    Includes origin, destination, optional intermediate waypoints, and various routing options to customize the calculated route based on 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

      Request travel time calculations for different traffic scenarios.

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

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

      Useful for comparing traffic impact and displaying "X minutes saved by leaving now".

      'none'
      
      computeTravelTimeFor: 'all'
      
    • OptionalextendedRouteRepresentations?: ExtendedRouteRepresentation[]

      Request extended progress information at route polyline points.

      Includes cumulative distance and/or time from start to each coordinate. When non-empty, the route features will contain additional property "progress" with 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)

      Useful for displaying progress during navigation or animating route visualization.

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

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

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

      Request turn-by-turn guidance instructions.

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

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

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

      The route will pass through these locations in the specified order.

      Requirements:

      • Minimum 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: 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 will 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 guidance-only and is returned solely when guidance is also requested.

      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

      Controls how entry points are used for routing.

      Entry points represent specific building entrances or facility access points. Using them improves 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
      'main-when-available'
      
      // 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', phonetics: 'IPA' },
    maxAlternatives: 2,
    costModel: {
    routeType: 'fast',
    avoid: ['tollRoads', 'motorways']
    },
    when: {
    option: 'departAt',
    date: new Date('2025-10-20T08:00:00Z')
    }
    };

    // Electric vehicle route with charging
    const evParams: CalculateRouteParams = {
    apiKey: 'your-api-key',
    locations: [[4.9, 52.3], [8.5, 50.1]],
    vehicle: {
    engineType: 'electric',
    model: {
    engine: {
    charging: { maxChargeKWH: 85 },
    consumption: {
    speedsToConsumptionsKWH: [
    { speedKMH: 50, consumptionUnitsPer100KM: 8 },
    { speedKMH: 80, consumptionUnitsPer100KM: 12 },
    { speedKMH: 120, consumptionUnitsPer100KM: 18 }
    ]
    }
    }
    },
    state: { currentChargeInkWh: 50 }
    }
    };