TomTom Maps for JavaScript
    Preparing search index...

    Function getRouteProgressBetween

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

      It calls calculateProgressAtRoutePoint for both indices and returns the start and end measurements with the delta, the distance and time covered between them.

      Parameters

      • route: Route

        The route whose properties.progress is interpolated.

      • 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, or undefined if either index can't be interpolated. calculateProgressAtRoutePoint lists all the 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`);
      }