This is the documentation of version 0.64.0. Go to the latest version, 1.0.0-rc.5.

Long distance EV routing

Request Access

Important note Long Distance EV Routing is unavailable on a Freemium or Pay As You Grow (PAYG) basis. Click the Request Access button above to contact our Sales team.

Given an electric vehicle with charging preferences, calculateRoute plans the charging stops a long journey needs: where to stop, how long to charge, and the battery level on every leg. Each stop the service inserts ends a leg of its own.

Activation

vehicle.preferences.chargingPreferences switches calculateRoute to the Long Distance EV Routing endpoint — there is nothing else to call, as What the routing SDK adds explains. The preferences set the minimum charge to keep, as a percentage or in kWh:

The vehicle must describe its charging, under vehicle.model.engine.charging (every field is in Vehicle configuration):

A predefined vehicle.model.variantId replaces all three, since the service holds that vehicle's charging model — give its charge and preferences in kWh, as no capacity is declared to convert percentages against. A variant is accepted on this endpoint only: calculateRoute rejects one without charging preferences.

Charging stops strategy

The top-level chargingStopsStrategy chooses how stops are planned, one of the importable chargingStopsStrategies:

It is only accepted alongside vehicle.preferences.chargingPreferences, and the types enforce it: a strategy requires a vehicle of type ElectricVehicleParamsWithChargingStops.

Example

import { calculateRoute } from '@tomtom-org/maps-sdk/services';

const routes = await calculateRoute({
    locations: [
        [4.9041, 52.3676],  // Amsterdam
        [13.4050, 52.5200]  // Berlin
    ],
    vehicle: {
        engineType: 'electric',
        model: {
            engine: {
                charging: {
                    maxChargeKWH: 75,
                    batteryCurve: [
                        { stateOfChargeInkWh: 50, maxPowerInkW: 200 },
                        { stateOfChargeInkWh: 70, maxPowerInkW: 100 },
                        { stateOfChargeInkWh: 80, maxPowerInkW: 40 },
                    ],
                    chargingConnectors: [
                        {
                            currentType: 'DC',
                            plugTypes: ['Combo_to_IEC_62196_Type_2_Base'],
                            efficiency: 0.9,
                            maxPowerInkW: 150
                        }
                    ]
                },
                consumption: {
                    speedsToConsumptionsKWH: [
                        { speedKMH: 50, consumptionUnitsPer100KM: 15 },
                        { speedKMH: 90, consumptionUnitsPer100KM: 18 },
                        { speedKMH: 120, consumptionUnitsPer100KM: 23 }
                    ]
                }
            }
        },
        state: { currentChargePCT: 80 },
        preferences: {
            chargingPreferences: {
                minChargeAtDestinationPCT: 20,
                minChargeAtChargingStopsPCT: 10
            }
        }
    }
});

const { summary, sections } = routes.features[0].properties;
console.log(`Legs: ${sections.leg.length}, charging: ${summary.totalChargingTimeInSeconds} s`);

Response structure

On top of the route object, a route with charging stops carries:

The percentage fields are converted against your maxChargeKWH, so a predefined variantId gets the kWh ones only. On the map, RoutingModule pins each charging stop — see Charging stop icons.

Time spent at a charging stop

Charging stops are chosen by the service, so they take no per-stop options — pauseDurationSeconds applies to your stops. What you can set is the time every charging stop takes on top of the charging itself — parking, plugging in, paying — on the charging model:

const charging = {
    maxChargeKWH: 75,
    // … battery curve and connectors as in the example above
    chargingTimeOffsetInSec: 900, // 15 minutes per stop (default 60 seconds)
};

Unsupported options

API reference

Related guides and examples

Related guides

Related examples