fix(bugs): Fix FindAWay Function with new package
This commit is contained in:
@@ -10,9 +10,8 @@ import '../shared/find_location_maps/model/prediction_model.dart';
|
||||
import '../shared/model/near_by_search_model.dart';
|
||||
|
||||
class MapServices {
|
||||
|
||||
Future<List<PlaceDetails>> getNearbyPlaces(double latitude, double longitude,
|
||||
String searchKey, int radius, String type) async {
|
||||
Future<List<PlaceDetails>> getNearbyPlaces(
|
||||
double latitude, double longitude, String searchKey, int radius, String type) async {
|
||||
List<PlaceDetails> result = [];
|
||||
var url = Uri.parse(
|
||||
'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=$searchKey&language=vi&location=$latitude%2C$longitude&radius=$radius&strictbounds=true&type=$type&key=${ApplicationConstants.MAP_KEY}');
|
||||
@@ -43,22 +42,23 @@ class MapServices {
|
||||
List<LatLng> polylineCoordinates = [];
|
||||
PolylinePoints polylinePoints = PolylinePoints();
|
||||
|
||||
// PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
|
||||
// ApplicationConstants.MAP_KEY,
|
||||
// PointLatLng(origin.latitude, origin.longitude),
|
||||
// PointLatLng(destination.latitude, destination.longitude),
|
||||
// travelMode: TravelMode.driving,
|
||||
// optimizeWaypoints: true);
|
||||
// if (result.points.isNotEmpty) {
|
||||
// for (var point in result.points) {
|
||||
// polylineCoordinates.add(LatLng(point.latitude, point.longitude));
|
||||
// }
|
||||
// return polylineCoordinates;
|
||||
// } else {
|
||||
// log("Lỗi khi tìm đường");
|
||||
// return [];
|
||||
// }
|
||||
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
|
||||
googleApiKey: ApplicationConstants.MAP_KEY,
|
||||
request: PolylineRequest(
|
||||
|
||||
origin: PointLatLng(origin.latitude, origin.longitude),
|
||||
destination: PointLatLng(destination.latitude, destination.longitude),
|
||||
mode: TravelMode.driving,
|
||||
optimizeWaypoints: true));
|
||||
if (result.points.isNotEmpty) {
|
||||
for (var point in result.points) {
|
||||
polylineCoordinates.add(LatLng(point.latitude, point.longitude));
|
||||
}
|
||||
return polylineCoordinates;
|
||||
} else {
|
||||
log("Lỗi khi tìm đường");
|
||||
return [];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user