getRouteBetweenCoordinates method
Future<PolylineResult>
getRouteBetweenCoordinates(
- String googleApiKey,
- PointLatLng origin,
- PointLatLng destination, {
- TravelMode travelMode = TravelMode.driving,
- List<
PolylineWayPoint> wayPoints = const [], - bool avoidHighways = false,
- bool avoidTolls = false,
- bool avoidFerries = true,
- bool optimizeWaypoints = false,
Get the list of coordinates between two geographical positions which can be used to draw polyline between this two positions
Implementation
Future<PolylineResult> getRouteBetweenCoordinates(
String googleApiKey, PointLatLng origin, PointLatLng destination,
{TravelMode travelMode = TravelMode.driving,
List<PolylineWayPoint> wayPoints = const [],
bool avoidHighways = false,
bool avoidTolls = false,
bool avoidFerries = true,
bool optimizeWaypoints = false}) async {
assert(googleApiKey.isNotEmpty, "Google API Key cannot be empty");
try {
var result = await NetworkUtil().getRouteBetweenCoordinates(
request: PolylineRequest(
apiKey: googleApiKey,
origin: origin,
destination: destination,
mode: travelMode,
wayPoints: wayPoints,
avoidHighways: avoidHighways,
avoidTolls: avoidTolls,
avoidFerries: avoidFerries,
alternatives: false,
optimizeWaypoints: optimizeWaypoints));
return result.isNotEmpty
? result[0]
: PolylineResult(errorMessage: "No result found");
} catch (e) {
rethrow;
}
}