diff --git a/lib/feature/map/widget/on_tap_marker_widget.dart b/lib/feature/map/widget/on_tap_marker_widget.dart index bb888bf..001d8a8 100644 --- a/lib/feature/map/widget/on_tap_marker_widget.dart +++ b/lib/feature/map/widget/on_tap_marker_widget.dart @@ -88,6 +88,7 @@ onTapMarker( otherMarkers, mapBloc, yourLocation, + deviceLocations, double.parse(device.settings!.latitude!), double.parse(device.settings!.longitude!), diff --git a/lib/feature/map/widget/show_direction_widget.dart b/lib/feature/map/widget/show_direction_widget.dart index e2bf828..65adff9 100644 --- a/lib/feature/map/widget/show_direction_widget.dart +++ b/lib/feature/map/widget/show_direction_widget.dart @@ -25,7 +25,7 @@ showDirections( TextEditingController(text: destinationLocation); ScaffoldMessenger.of(context).showSnackBar( SnackBar( - backgroundColor: Colors.transparent, + backgroundColor: Theme.of(context).colorScheme.surface, // dismissDirection: DismissDirection.none, duration: const Duration(minutes: 5), content: Column( @@ -50,8 +50,8 @@ showDirections( devicelng, 13.0, ); - List polylineCoordinates = []; - mapBloc.sinkPolylines.add(polylineCoordinates); + // List polylineCoordinates = []; + mapBloc.sinkPolylines.add([]); markers.clear(); if (context.mounted) { ScaffoldMessenger.of(context).hideCurrentSnackBar(); diff --git a/lib/main.dart b/lib/main.dart index 221d7a1..7bf9b6a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -20,8 +20,6 @@ Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); await setupFlutterNotifications(); 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}'); } diff --git a/lib/product/services/map_services.dart b/lib/product/services/map_services.dart index 241324a..726ad22 100644 --- a/lib/product/services/map_services.dart +++ b/lib/product/services/map_services.dart @@ -10,9 +10,8 @@ import '../shared/find_location_maps/model/prediction_model.dart'; import '../shared/model/near_by_search_model.dart'; class MapServices { - - Future> getNearbyPlaces(double latitude, double longitude, - String searchKey, int radius, String type) async { + Future> getNearbyPlaces( + double latitude, double longitude, String searchKey, int radius, String type) async { List 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 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 []; } - -} \ No newline at end of file +}