TomTom Maps for JavaScript
    Preparing search index...

    Function getProgressAtNearestRoutePoint

    • Returns the geographic coordinate and cumulative progress values at the point on a route nearest to the given location.

      Projects point onto the route line using nearestPointOnLine, then linearly interpolates the progress data at the snapped position between the two bracketing route vertices.

      Parameters

      • route: Route

        The route to query. Must contain properties.progress data.

      • point: HasLngLat

        The reference location to snap to the route.

      Returns RouteCoordinateAtProgress | undefined

      Interpolated RouteCoordinateAtProgress at the nearest point, or undefined when:

      • the route has no progress data
      • the route has fewer than 2 coordinates
      • the progress data is incomplete for the snapped position
      const result = getProgressAtNearestRoutePoint(route, { lng: 4.92, lat: 52.32 });
      if (result) {
      console.log(`Nearest point: [${result.position}]`);
      console.log(`${result.distanceInMeters} m from route start`);
      console.log(`${result.travelTimeInSeconds} s travel time from route start`);
      }