update distance calculation to from current location
This commit is contained in:
@ -66,11 +66,12 @@ class _ListWidgetState extends State<ListWidget> {
|
|||||||
|
|
||||||
Future<String> matrixDistance(int i) async {
|
Future<String> matrixDistance(int i) async {
|
||||||
// Create two destinations directly from indexController.locations[0].collection
|
// Create two destinations directly from indexController.locations[0].collection
|
||||||
Destination dest1 = createDestination(indexController.locations[0].collection[i]);
|
Destination desCurr = Destination(lat: indexController.current_lat, lon: indexController.current_lon);
|
||||||
Destination dest2 = createDestination(indexController.locations[0].collection[i+1]);
|
//Destination dest1 = createDestination(indexController.locations[0].collection[0]);
|
||||||
|
Destination dest2 = createDestination(indexController.locations[0].collection[i]);
|
||||||
|
|
||||||
// Get the distance between these two destinations
|
// Get the distance between these two destinations
|
||||||
final res = await MatrixService.getDestinations([dest1, dest2]);
|
final res = await MatrixService.getDestinations([desCurr, dest2]);
|
||||||
|
|
||||||
return res["routes"][0]["legs"][0]["distance"]["text"];
|
return res["routes"][0]["legs"][0]["distance"]["text"];
|
||||||
//print("matrix result is ${i} : ${res["routes"][0]["legs"][0]["distance"]["text"]} ");
|
//print("matrix result is ${i} : ${res["routes"][0]["legs"][0]["distance"]["text"]} ");
|
||||||
|
|||||||
Reference in New Issue
Block a user