TomTom Maps for JavaScript
    Preparing search index...

    Type Alias CalculateRouteParams

    CalculateRouteParams: CommonServiceParams<
        CalculateRouteRequestAPI,
        CalculateRouteResponseAPI,
    > & CommonRoutingParams & {
        computeAdditionalTravelTimeFor?: 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

    • OptionalcomputeAdditionalTravelTimeFor?: ComputeTravelTimeFor

      Request additional 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'
      
      computeAdditionalTravelTimeFor: '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.

      ['distance', 'travelTime']
      
      extendedRouteRepresentations: ['distance', 'travelTime']
      
    • 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',
      version: 2,
      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
      • (not supported) Waypoint objects with radius for circle waypoints
      // 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
      ]

      // (not supported) Waypoint objects with radius for circle waypoints
      locations: [
      [4.9, 52.3],
      {
      type: 'Feature',
      geometry: { type: 'Point', coordinates: [4.7, 52.1] },
      properties: { radiusMeters: 5000 }
      },
      [4.5, 51.9]
      ]
    • 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 }
    }
    };