update to routing

This commit is contained in:
Mohamed Nouffer
2022-09-29 15:32:33 +05:30
parent 0ca322e278
commit 0470e1f27f
11 changed files with 120 additions and 70 deletions

View File

@ -14,6 +14,7 @@ class MatrixService{
String locs = "";
String origin = "";
String destination = "";
int i = 0;
for(Destination d in destinations){
@ -21,6 +22,14 @@ class MatrixService{
if(i==0){
origin = "${d.lat}, ${d.lon}";
i++;
continue;
}
if(i == (destinations.length - 1)){
destination = "${d.lat}, ${d.lon}";
i++;
continue;
}
print("lat is ${d.lat}, long is ${d.lon}");
@ -28,6 +37,8 @@ class MatrixService{
i++;
}
locs = "optimize:false|${locs}";
String _mode = "walking";
switch (destinationController.travelMode.value) {
case 1:
@ -42,7 +53,7 @@ class MatrixService{
}
Map<String, dynamic> cats = {};
String url = "https://maps.googleapis.com/maps/api/distancematrix/json?destinations=${locs}&mode=${_mode}&origins=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
String url = "https://maps.googleapis.com/maps/api/directions/json?destination=${destination}&mode=${_mode}&waypoints=${locs}&origin=${origin}&key=AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE";
print(url);
final http.Response response = await http.get(
Uri.parse(url),