getTrip method

Future<Road> getTrip({
  1. required List<LngLat> waypoints,
  2. RoadType roadType = RoadType.car,
  3. bool roundTrip = true,
  4. SourceGeoPointOption source = SourceGeoPointOption.any,
  5. DestinationGeoPointOption destination = DestinationGeoPointOption.any,
  6. bool steps = true,
  7. Overview overview = Overview.full,
  8. Geometries geometries = Geometries.polyline,
  9. Languages language = Languages.en,
})

getTrip

this method used to get route from trip service api used if you have more that 10 waypoint to generate route will more accurate than getRoad.

Please note that if one sets roundTrip to false, then source and destination must be provided.

Implementation

Future<Road> getTrip({
  required List<LngLat> waypoints,
  RoadType roadType = RoadType.car,
  bool roundTrip = true,
  SourceGeoPointOption source = SourceGeoPointOption.any,
  DestinationGeoPointOption destination = DestinationGeoPointOption.any,
  bool steps = true,
  Overview overview = Overview.full,
  Geometries geometries = Geometries.polyline,
  Languages language = Languages.en,
}) async {
  if (!roundTrip &&
      (source == SourceGeoPointOption.any ||
          destination == DestinationGeoPointOption.any)) {
    return Road.empty();
  }
  String urlReq = generateTripPath(
    oSRMServer,
    waypoints.toWaypoints(),
    roadType: roadType,
    roundTrip: roundTrip,
    source: source,
    destination: destination,
    steps: steps,
    overview: overview,
    geometries: geometries,
  );
  final response = await dio.get(urlReq);
  if (response.statusCode == 200) {
    final Map<String, dynamic> responseJson = response.data;
    return compute(
      parseTrip,
      ParserTripComputeArg(
        tripJson: responseJson,
        langCode: language.name,
      ),
    );
  } else {
    return Road.withError();
  }
}