update
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:ffi';
|
||||
import 'package:flutter_polyline_points/flutter_polyline_points.dart';
|
||||
//import 'package:google_maps_webservice/directions.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
|
||||
@ -36,6 +39,35 @@ class DestinationService{
|
||||
return cats;
|
||||
}
|
||||
|
||||
static Future<List<PointLatLng>>? getDestinationLine(List<dynamic> destinations) async{
|
||||
PolylinePoints polylinePoints = PolylinePoints();
|
||||
|
||||
//print("##### @@@@@ ${destinations[0]["location"]["geometry"]["coordinates"][0][1]}");
|
||||
PointLatLng origin = PointLatLng(destinations[0]["location"]["geometry"]["coordinates"][0][1], destinations[0]["location"]["geometry"]["coordinates"][0][0]);
|
||||
PointLatLng dest = PointLatLng(destinations[destinations.length -1]["location"]["geometry"]["coordinates"][0][1], destinations[destinations.length -1]["location"]["geometry"]["coordinates"][0][0]);
|
||||
|
||||
|
||||
List<PolylineWayPoint> wayPoints = [];
|
||||
int i=0;
|
||||
for(dynamic d in destinations){
|
||||
if(i == 0 || i == (destinations.length -1)){
|
||||
i+=1;
|
||||
continue;
|
||||
}
|
||||
double la = d["location"]["geometry"]["coordinates"][0][1]as double;
|
||||
double ln = d["location"]["geometry"]["coordinates"][0][0] as double;
|
||||
PolylineWayPoint pwp = PolylineWayPoint(location: "${la},${ln}", stopOver: true);
|
||||
//print("----- UUUUUU ${pwp}");
|
||||
//PointLatLng wp = PointLatLng(d["Location"]["geometry"][0][1], d["Location"]["geometry"][0][0]);
|
||||
wayPoints.add(pwp);
|
||||
i+=1;
|
||||
}
|
||||
//PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", PointLatLng(35.389282, 136.498027), PointLatLng(36.285848, 137.575186));
|
||||
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates("AIzaSyAUBI1ablMKuJwGj2-kSuEhvYxvB1A-mOE", origin,dest, travelMode: TravelMode.driving, wayPoints: wayPoints);
|
||||
//print("#####@@@@@ ${result.points}");
|
||||
return result.points;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user