TomTom Maps for JavaScript
    Preparing search index...

    Type Alias AlongRouteSearchParams

    AlongRouteSearchParams: CommonSearchParams<
        AlongRouteSearchRequestAPI,
        AlongRouteSearchResponseAPI,
    > & {
        maxDetourTimeSeconds: number;
        route: LineString
        | Route
        | Position[];
        sortBy?: AlongRouteSortBy;
    }

    Parameters for searching places along a route.

    Along-route search finds POIs near a provided route geometry and ranks them by the detour cost (time or distance offset) required to visit them.

    Type Declaration

    • maxDetourTimeSeconds: number

      Maximum allowed detour time in seconds.

      Only POIs reachable within this additional travel time from the route will be returned. Controls the width of the search corridor.

      maxDetourTimeSeconds: 300  // 5-minute detour budget
      
    • route: LineString | Route | Position[]

      Route geometry to search along.

      Accepts any of three forms:

      • Route feature as returned by calculateRoute (most common)
      • LineString GeoJSON geometry object
      • Position[] — a plain array of [longitude, latitude] coordinate pairs

      Coordinates must always be in [longitude, latitude] order.

      // Route Feature from calculateRoute (most common)
      route: routeResult.features[0]

      // GeoJSON LineString geometry
      route: routeResult.features[0].geometry

      // Plain coordinate array
      route: [[4.9, 52.37], [4.95, 52.28], [5.1, 52.09]]
    • OptionalsortBy?: AlongRouteSortBy

      Sort order for the results.

      'detourTime'
      
      sortBy: 'detourOffset'  // order by position along the route
      

    Key Features:

    • Search for POIs within a detour budget from the route
    • Sort results by detour time or route offset
    • Combine with POI category and brand filters
    • Use directly with a calculateRoute result

    Use Cases:

    • Find fuel stations or EV chargers along a trip
    • Locate rest stops or restaurants near a route
    • Surface services reachable within a time budget
    // Find coffee shops within a 5-minute detour from a route
    const results = await search({
    route: routeResult.features[0],
    maxDetourTimeSeconds: 300,
    query: 'coffee',
    });

    // Find EV charging stations using a plain coordinate array
    const chargers = await search({
    route: [[4.9, 52.37], [4.95, 52.28], [5.1, 52.09]],
    maxDetourTimeSeconds: 600,
    poiCategories: ['ELECTRIC_VEHICLE_STATION'],
    sortBy: 'detourOffset',
    });