fetchDirections static method
Implementation
static Future<DrivingDirections> fetchDirections(
String apiKey, String coordinates,
{bool alternatives = false,
bool steps = false,
String geometries = 'polyline',
String overview = 'full',
bool annotations = false}) async {
final String apiUrl =
'https://us1.locationiq.com/v1/directions/driving/$coordinates';
final String url =
'$apiUrl?key=$apiKey&alternatives=$alternatives&steps=$steps&geometries=$geometries&overview=$overview&annotations=$annotations';
final response = await http.get(Uri.parse(url));
if (response.statusCode == 200) {
final Map<String, dynamic> data = json.decode(response.body);
return DrivingDirections.fromJson(data);
} else {
throw Exception('Impossible de récupérer les directions');
}
}