fix(bugs): Fix FindAWay Function with new package
This commit is contained in:
@@ -88,6 +88,7 @@ onTapMarker(
|
|||||||
otherMarkers,
|
otherMarkers,
|
||||||
mapBloc,
|
mapBloc,
|
||||||
yourLocation,
|
yourLocation,
|
||||||
|
|
||||||
deviceLocations,
|
deviceLocations,
|
||||||
double.parse(device.settings!.latitude!),
|
double.parse(device.settings!.latitude!),
|
||||||
double.parse(device.settings!.longitude!),
|
double.parse(device.settings!.longitude!),
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ showDirections(
|
|||||||
TextEditingController(text: destinationLocation);
|
TextEditingController(text: destinationLocation);
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||||
// dismissDirection: DismissDirection.none,
|
// dismissDirection: DismissDirection.none,
|
||||||
duration: const Duration(minutes: 5),
|
duration: const Duration(minutes: 5),
|
||||||
content: Column(
|
content: Column(
|
||||||
@@ -50,8 +50,8 @@ showDirections(
|
|||||||
devicelng,
|
devicelng,
|
||||||
13.0,
|
13.0,
|
||||||
);
|
);
|
||||||
List<LatLng> polylineCoordinates = [];
|
// List<LatLng> polylineCoordinates = [];
|
||||||
mapBloc.sinkPolylines.add(polylineCoordinates);
|
mapBloc.sinkPolylines.add([]);
|
||||||
markers.clear();
|
markers.clear();
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
|||||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||||
await setupFlutterNotifications();
|
await setupFlutterNotifications();
|
||||||
showFlutterNotification(message);
|
showFlutterNotification(message);
|
||||||
// If you're going to use other Firebase services in the background, such as Firestore,
|
|
||||||
// make sure you call `initializeApp` before using other Firebase services.
|
|
||||||
print('Handling a background message ${message.messageId}');
|
print('Handling a background message ${message.messageId}');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,8 @@ import '../shared/find_location_maps/model/prediction_model.dart';
|
|||||||
import '../shared/model/near_by_search_model.dart';
|
import '../shared/model/near_by_search_model.dart';
|
||||||
|
|
||||||
class MapServices {
|
class MapServices {
|
||||||
|
Future<List<PlaceDetails>> getNearbyPlaces(
|
||||||
Future<List<PlaceDetails>> getNearbyPlaces(double latitude, double longitude,
|
double latitude, double longitude, String searchKey, int radius, String type) async {
|
||||||
String searchKey, int radius, String type) async {
|
|
||||||
List<PlaceDetails> result = [];
|
List<PlaceDetails> result = [];
|
||||||
var url = Uri.parse(
|
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}');
|
'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 = [];
|
List<LatLng> polylineCoordinates = [];
|
||||||
PolylinePoints polylinePoints = PolylinePoints();
|
PolylinePoints polylinePoints = PolylinePoints();
|
||||||
|
|
||||||
// PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
|
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
|
||||||
// ApplicationConstants.MAP_KEY,
|
googleApiKey: ApplicationConstants.MAP_KEY,
|
||||||
// PointLatLng(origin.latitude, origin.longitude),
|
request: PolylineRequest(
|
||||||
// PointLatLng(destination.latitude, destination.longitude),
|
|
||||||
// travelMode: TravelMode.driving,
|
origin: PointLatLng(origin.latitude, origin.longitude),
|
||||||
// optimizeWaypoints: true);
|
destination: PointLatLng(destination.latitude, destination.longitude),
|
||||||
// if (result.points.isNotEmpty) {
|
mode: TravelMode.driving,
|
||||||
// for (var point in result.points) {
|
optimizeWaypoints: true));
|
||||||
// polylineCoordinates.add(LatLng(point.latitude, point.longitude));
|
if (result.points.isNotEmpty) {
|
||||||
// }
|
for (var point in result.points) {
|
||||||
// return polylineCoordinates;
|
polylineCoordinates.add(LatLng(point.latitude, point.longitude));
|
||||||
// } else {
|
}
|
||||||
// log("Lỗi khi tìm đường");
|
return polylineCoordinates;
|
||||||
// return [];
|
} else {
|
||||||
// }
|
log("Lỗi khi tìm đường");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user