TomTom Maps for JavaScript
    Preparing search index...

    Function getRouteProgressBetween

    • Calculates progress measurements for a segment between two arbitrary points on the route path.

      Calls calculateProgressAtRoutePoint for both indices and exposes the start and end measurements together with the delta (distance and time covered between them).

      Parameters

      • route: Route

        The route whose properties.progress will be used for interpolation.

      • startPathIndex: number

        Zero-based index of the segment start in the route's coordinate array.

      • endPathIndex: number

        Zero-based index of the segment end in the route's coordinate array.

      Returns RouteSegmentProgress | undefined

      A RouteSegmentProgress object, or undefined when either index cannot be interpolated (see calculateProgressAtRoutePoint for the full list of conditions).

      const result = getRouteProgressBetween(route, 10, 60);
      if (result) {
      console.log(`Segment starts ${result.start.distanceInMeters} m from route origin`);
      console.log(`Segment ends ${result.end.distanceInMeters} m from route origin`);
      console.log(`Segment length ${result.delta.distanceInMeters} m`);
      console.log(`Segment takes ${result.delta.travelTimeInSeconds} s`);
      }