directionsMultiRouteGeoJsonPost method

Future<GeoJsonFeatureCollection> directionsMultiRouteGeoJsonPost({
  1. required List<ORSCoordinate> 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 coordinates from the openrouteservice API, and returns the entire geojson GeoJsonFeatureCollection containing the response data.

To get only the parsed route coordinates, use ORSDirections.directionsMultiRouteCoordsPost.

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

Implementation

Future<GeoJsonFeatureCollection> directionsMultiRouteGeoJsonPost({
  required List<ORSCoordinate> 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 {
  // If a path parameter override is provided, use it.
  final ORSProfile chosenPathParam = profileOverride ?? _defaultProfile;

  // Build the request URL.
  final Uri uri =
      Uri.parse('$_directionsEndpointURL/${chosenPathParam.name}/geojson');

  // Ready data to be sent.
  final Map<String, dynamic> queryParameters = <String, dynamic>{
    'coordinates': coordinates
        .map<List<double>>(
          (ORSCoordinate coordinate) =>
              <double>[coordinate.longitude, coordinate.latitude],
        )
        .toList(),
    'alternative_routes': alternativeRoutes,
    'attributes': attributes,
    'continue_straight': continueStraight,
    'elevation': elevation,
    'extra_info': extraInfo,
    'geometry_simplify': geometrySimplify,
    'id': id,
    'instructions': instructions,
    'instructions_format': instructionsFormat,
    'language': language,
    'maneuvers': maneuvers,
    'options': options,
    'preference': preference,
    'radiuses': radiuses,
    'roundabout_exits': roundaboutExits,
    'skip_segments': skipSegments,
    'suppress_warnings': suppressWarnings,
    'units': units,
    'geometry': geometry,
    'maximum_speed': maximumSpeed,
  }..removeWhere((String _, dynamic value) => value == null);

  // Fetch the data.
  final Map<String, dynamic> data =
      await _openRouteServicePost(uri: uri, data: queryParameters);
  return GeoJsonFeatureCollection.fromJson(data);
}