TomTom Maps for JavaScript
    Preparing search index...

    Type Alias VehicleState<E>

    VehicleState: GenericVehicleState & (
        E extends "combustion"
            ? CombustionVehicleState
            : E extends "electric" ? ElectricVehicleState : {}
    )

    Vehicle state - current conditions that change during travel.

    Type Parameters

    • E extends VehicleEngineType = undefined

      The engine type (combustion, electric, or undefined for generic)

    Represents dynamic properties that vary during a journey:

    • Fuel or battery level
    • Current heading/direction

    Unlike the vehicle model (static properties), state changes as the vehicle travels and consumes fuel/energy.

    // Generic vehicle with heading
    const genericState: VehicleState = {
    heading: 90 // Facing east
    };

    // Combustion vehicle with fuel
    const combustionState: VehicleState<'combustion'> = {
    currentFuelInLiters: 45,
    heading: 180
    };

    // Electric vehicle with battery percentage
    const evState: VehicleState<'electric'> = {
    currentChargePCT: 75,
    heading: 0
    };

    // Electric vehicle with absolute energy
    const evKwhState: VehicleState<'electric'> = {
    currentChargeInkWh: 60,
    heading: 45
    };