This is the documentation of version 1.0.0-rc.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias LegSectionProps

    LegSectionProps: Omit<SectionProps, "startPointIndex" | "endPointIndex"> & {
        endPointIndex?: number;
        originalWaypointIndex?: number;
        startPointIndex?: number;
        summary: LegSummary;
    }

    A route section for a leg, the portion of route between two consecutive waypoints.

    It is a top-level section that covers the entire journey segment.

    Type Declaration

    • OptionalendPointIndex?: number

      The index in the route coordinates where this leg ends, present only if the route polyline geometry is available.

    • OptionaloriginalWaypointIndex?: number

      The index of the waypoint this leg ends at, in the locations the route was requested with.

      A leg does not always end at the location with the same index. A path location expands into legs of its own, so legs[i] is not reliably the leg arriving at locations[i + 1]. This index maps a leg back to the stop the caller passed.

      It is absent on the final leg, and on legs that end somewhere the caller did not ask for.

      // Which of the stops I passed does this leg arrive at?
      const index = leg.originalWaypointIndex;
      const stop = index === undefined ? undefined : locations[index];
    • OptionalstartPointIndex?: number

      The index in the route coordinates where this leg starts, present only if the route polyline geometry is available.

    • summary: LegSummary

      The summary statistics of this leg of the journey, with its departure and arrival times, distances and durations.

    For example:

    • A→B route: 1 leg (A to B)
    • A→B→C route: 2 legs (A to B, then B to C)
    • A path location (route reconstruction): one leg per leg the path was planned with
    const leg: LegSectionProps = {
    id: 'leg-1',
    summary: {
    departureTime: new Date(),
    arrivalTime: new Date(),
    lengthInMeters: 50000,
    travelTimeInSeconds: 3600,
    // ... other summary fields
    },
    startPointIndex: 0,
    endPointIndex: 250
    };