9/17/1
This commit is contained in:
@@ -30,6 +30,7 @@ class MapController extends GetxController {
|
||||
LatLng mydestination = const LatLng(32.115295, 36.064773);
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
List<LatLng> carsLocationByPassenger = [];
|
||||
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
|
||||
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
|
||||
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
|
||||
double height = 150;
|
||||
@@ -57,6 +58,7 @@ class MapController extends GetxController {
|
||||
late LatLng northeast;
|
||||
List<CarLocationModel> carLocations = <CarLocationModel>[];
|
||||
var dataCarsLocationByPassenger;
|
||||
var datadriverCarsLocationToPassengerAfterApplied;
|
||||
CarLocation? nearestCar;
|
||||
late Timer markerReloadingTimer;
|
||||
bool shouldFetch = true; // Flag to determine if fetch should be executed
|
||||
@@ -226,7 +228,7 @@ class MapController extends GetxController {
|
||||
|
||||
void timerEnded() async {
|
||||
print('Timer ended');
|
||||
// refuseOrder();
|
||||
runEvery50SecondsUntilConditionMet();
|
||||
isCancelRidePageShown = false;
|
||||
update();
|
||||
}
|
||||
@@ -437,6 +439,59 @@ class MapController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future getDriverCarsLocationToPassengerAfterApplied() async {
|
||||
driverCarsLocationToPassengerAfterApplied = [];
|
||||
|
||||
var res = await CRUD().get(
|
||||
link: AppLink.getDriverCarsLocationToPassengerAfterApplied,
|
||||
payload: {
|
||||
'driver_id': dataCarsLocationByPassenger['message'][0]['driver_id']
|
||||
});
|
||||
|
||||
datadriverCarsLocationToPassengerAfterApplied = jsonDecode(res);
|
||||
|
||||
driverCarsLocationToPassengerAfterApplied.add(LatLng(
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['latitude']),
|
||||
double.parse(datadriverCarsLocationToPassengerAfterApplied['message'][0]
|
||||
['longitude'])));
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
Future runEvery50SecondsUntilConditionMet() async {
|
||||
// Calculate the duration of the trip in minutes.
|
||||
double tripDurationInMinutes = duration1 / 60;
|
||||
int loopCount = tripDurationInMinutes.ceil();
|
||||
// If the trip duration is less than or equal to 50 minutes, then break the loop.
|
||||
for (var i = 0; i < loopCount; i++) {
|
||||
// Wait for 50 seconds.
|
||||
await Future.delayed(const Duration(
|
||||
seconds:
|
||||
50)); // Run the `getDriverCarsLocationToPassengerAfterApplied()` function.
|
||||
await getDriverCarsLocationToPassengerAfterApplied();
|
||||
reloadMarkerDriverCarsLocationToPassengerAfterApplied();
|
||||
}
|
||||
}
|
||||
|
||||
void reloadMarkerDriverCarsLocationToPassengerAfterApplied() {
|
||||
// Clear existing markers
|
||||
markers.clear();
|
||||
|
||||
for (var item in driverCarsLocationToPassengerAfterApplied) {
|
||||
final marker = Marker(
|
||||
infoWindow: InfoWindow(title: '${item.latitude} minutes'),
|
||||
markerId: MarkerId(item.toString()),
|
||||
position: LatLng(item.latitude, item.longitude),
|
||||
);
|
||||
markers.add(marker);
|
||||
update();
|
||||
mapController?.animateCamera(
|
||||
CameraUpdate.newLatLng(LatLng(item.latitude, item.longitude)));
|
||||
update();
|
||||
} // Update the map with the new markers
|
||||
}
|
||||
|
||||
LatLngBounds calculateBounds(
|
||||
double centerLat, double centerLng, double radius) {
|
||||
// double radius = 4000; // 10 km in meters
|
||||
|
||||
Reference in New Issue
Block a user