TomTom Maps for JavaScript
    Preparing search index...

    Type Alias CommonRoutingParams

    Common parameters shared across all routing service requests.

    These parameters configure how routes are calculated, including optimization strategy, vehicle characteristics, timing constraints, and travel preferences. They provide a consistent interface across different routing services.

    Most routing services (calculateRoute, calculateMatrixRoute, calculateReachableRange) accept these parameters to customize route calculation. They control:

    • What to optimize for (time, distance, fuel)
    • Vehicle constraints and capabilities
    • When to travel (affecting traffic)
    • What features to avoid
    • Mode of transportation

    Service Compatibility:

    • calculateRoute: All parameters supported
    • calculateMatrixRoute: Subset of parameters
    • calculateReachableRange: Subset of parameters
    // Standard car route avoiding tolls
    const routingParams: CommonRoutingParams = {
    costModel: {
    routeType: 'fast',
    traffic: 'live',
    avoid: ['tollRoads']
    },
    travelMode: 'car',
    when: {
    option: 'departAt',
    date: new Date('2025-10-20T08:00:00Z')
    }
    };

    // Electric vehicle route with consumption model
    const evRoutingParams: CommonRoutingParams = {
    costModel: {
    routeType: 'efficient',
    traffic: 'live'
    },
    travelMode: 'car',
    vehicle: {
    engineType: 'electric',
    model: {
    dimensions: {
    weightKG: 2000
    },
    engine: {
    consumption: {
    speedToConsumption: [
    { speedKMH: 50, consumptionUnitsPer100KM: 15 },
    { speedKMH: 90, consumptionUnitsPer100KM: 18 },
    { speedKMH: 120, consumptionUnitsPer100KM: 22 }
    ]
    }
    }
    },
    state: {
    currentChargeInkWh: 60
    }
    }
    };

    // Truck route with restrictions
    const truckParams: CommonRoutingParams = {
    costModel: {
    routeType: 'short',
    avoid: ['tollRoads', 'ferries']
    },
    travelMode: 'truck',
    vehicle: {
    model: {
    dimensions: {
    lengthMeters: 16.5,
    widthMeters: 2.5,
    heightMeters: 4.0,
    weightKG: 40000
    },
    restrictions: {
    restrictions: {
    commercial: true,
    maxSpeedKMH: 90
    }
    }
    }
    }
    };
    type CommonRoutingParams = {
        apiVersion?: number;
        costModel?: CostModel;
        travelMode?: TravelMode;
        vehicle?: VehicleParameters;
        when?: DepartArriveParams;
    }
    Index

    Properties

    apiVersion?: number

    The version of the API to use.

    • The SDK will use the right default when not specified.
    • Use it only if you really need to target a specific API version.
    costModel?: CostModel

    Criteria that specifies what paths to prefer during routing.

    travelMode?: TravelMode

    The primary means of transportation to be used while routing.

    The travel mode for the requested route. Note that the requested travelMode may not be available for the entire route. Where the requested travelMode is not available for a particular section, the element of the response for that section will be 'other'.

    None
    

    Parameters for the vehicle that will be used to drive the route.

    Specifies when to depart or arrive. If past dates are supplied or in a way that are impossible to achieve (e.g. an imminent arrival date for a long route), then it will default to departing now.

    depart now