getTrip method
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,
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();
}
}