getMultiRouteCoordinates method

Future<List<Coordinate>> getMultiRouteCoordinates({
  1. required List<Coordinate> coordinates,
  2. Object? alternativeRoutes,
  3. List<String>? attributes,
  4. bool continueStraight = false,
  5. bool? elevation,
  6. List<String>? extraInfo,
  7. bool geometrySimplify = false,
  8. String? id,
  9. bool instructions = true,
  10. String instructionsFormat = 'text',
  11. String language = 'en',
  12. bool maneuvers = false,
  13. Object? options,
  14. String preference = 'recommended',
  15. List<int>? radiuses,
  16. bool roundaboutExits = false,
  17. List<int>? skipSegments,
  18. bool suppressWarnings = false,
  19. String units = 'm',
  20. bool geometry = true,
  21. int? maximumSpeed,
  22. ORSProfile? profileOverride,
})

Fetches the Direction Route information for the route connecting the various given coordinates, from the openrouteservice API, and then parses it's coordinates to a List of Coordinate objects.

To return the entire GeoJsonFeatureCollection containing the response data, use ORSDirections.getRouteDirectionsGeoJson.

Information about the endpoint and all the parameters can be found at: https://openrouteservice.org/dev/#/api-docs/v2/directions/{profile}/geojson/post

Implementation

Future<List<Coordinate>> getMultiRouteCoordinates({
  required List<Coordinate> coordinates,
  Object? alternativeRoutes,
  List<String>? attributes,
  bool continueStraight = false,
  bool? elevation,
  List<String>? extraInfo,
  bool geometrySimplify = false,
  String? id,
  bool instructions = true,
  String instructionsFormat = 'text',
  String language = 'en',
  bool maneuvers = false,
  Object? options,
  String preference = 'recommended',
  List<int>? radiuses,
  bool roundaboutExits = false,
  List<int>? skipSegments,
  bool suppressWarnings = false,
  String units = 'm',
  bool geometry = true,
  int? maximumSpeed,
  ORSProfile? profileOverride,
}) async {
  // Fetch and parse the data.
  final GeoJsonFeatureCollection featureCollection =
      await getMultiRouteDirectionsGeoJson(
    coordinates: coordinates,
    alternativeRoutes: alternativeRoutes,
    attributes: attributes,
    continueStraight: continueStraight,
    elevation: elevation,
    extraInfo: extraInfo,
    geometrySimplify: geometrySimplify,
    id: id,
    instructions: instructions,
    instructionsFormat: instructionsFormat,
    language: language,
    maneuvers: maneuvers,
    options: options,
    preference: preference,
    radiuses: radiuses,
    roundaboutExits: roundaboutExits,
    skipSegments: skipSegments,
    suppressWarnings: suppressWarnings,
    units: units,
    geometry: geometry,
    maximumSpeed: maximumSpeed,
    profileOverride: profileOverride,
  );
  return featureCollection.features.first.geometry.coordinates.first;
}