route method

Future<RouteResponse> route(
  1. RouteRequest options
)

route Finds the fastest route between coordinates in the supplied order. Parameters:

  • alternatives: search for alternative routes and return as well
  • steps: return route steps for each route leg
  • annotations: return annotations for each route leg for duration, nodes, distance, weight, datasources, speed
  • geometries: return route geometry as polyline or geojson
  • overview: add overview geometry either full, simplified according to highest zoom level it could be display on, or not at all
  • continueStraight: forces the route to keep going straight at waypoints constraining uturns there even if it would be faster
  • waypoints: array of Waypoint objects Examples:

cURL example

curl "http://router.project-osrm.org/route/v1/driving/13.388860,52.517037;13.385983,52.496891?steps=true&alternatives=true"

Dart example

final route = await osrm.route(
  RouteOptions(
     waypoints: [
      Waypoint(location: Location(latitude: 52.4224, longitude: 13.333086)),
      Waypoint(location: Location(latitude: 52.4224, longitude: 13.333086)),
      Waypoint(location: Location(latitude: 52.4224, longitude: 13.333086)),
    ],
    alternatives: true,
    steps: true,
    annotations: OsrmAnnotation.true_, // or OsrmAnnotation.false_ or OsrmAnnotation.number(2)
    geometries: Geometries.geojson,
    overview: Overview.full,
    continueStraight: true,
  ),
);

Implementation

Future<RouteResponse> route(RouteRequest options) async {
  final response = await source.request(options);
  return RouteResponse.fromMap(response);
}