This commit is contained in:
Hamza-Ayed
2024-03-31 14:12:27 +03:00
parent 874be94864
commit 5df659ecd5
2 changed files with 137 additions and 113 deletions

View File

@@ -1114,20 +1114,33 @@ class MapPassengerController extends GetxController {
var json = dataCarsLocationByPassenger['message'][i];
print(json);
CarLocationModel model = CarLocationModel.fromJson(json);
carLocationsModels.add(model);
// currentDriverLocation = LatLng(
// double.parse(json['latitude']),
// double.parse(json['longitude']),
// );
// // headingList = double.parse(json['heading']);
// // Update lastDriverLocation on each iteration
// previousLocationOfDrivers = currentDriverLocation;
// carsLocationByPassenger.add(currentDriverLocation);
// // carsLocationByPassenger.add(headingList);
driversToken.add(json['token']);
if (carLocationsModels.length < i + 1) {
carLocationsModels.add(model);
markers.add(
Marker(
markerId: MarkerId(json['latitude']),
position: LatLng(
double.parse(json['latitude']),
double.parse(json['longitude']),
),
rotation: double.parse(json['heading']),
icon: carIcon,
),
);
driversToken.add(json['token']);
} else {
carLocationsModels[i] = model;
markers[i] = Marker(
markerId: MarkerId(json['latitude']),
position: LatLng(
double.parse(json['latitude']),
double.parse(json['longitude']),
),
rotation: double.parse(json['heading']),
icon: carIcon,
);
driversToken[i] = json['token'];
}
}
update();
@@ -1176,30 +1189,30 @@ class MapPassengerController extends GetxController {
// Clear existing markers
markers.clear();
update();
for (var i = 0; i < driverCarsLocationToPassengerAfterApplied.length; i++) {
// for (var i = 0; i < driverCarsLocationToPassengerAfterApplied.length; i++) {
// }
// for (var item in driverCarsLocationToPassengerAfterApplied) {
final driverAcceptedMarker = Marker(
onTap: () => print('marker pressed'),
infoWindow: InfoWindow(
title:
'${driverCarsLocationToPassengerAfterApplied[i].latitude} minutes'),
markerId: MarkerId(
datadriverCarsLocationToPassengerAfterApplied['message'][0]['id']
.toString()),
position: LatLng(driverCarsLocationToPassengerAfterApplied[i].latitude,
driverCarsLocationToPassengerAfterApplied[i].longitude),
rotation: datadriverCarsLocationToPassengerAfterApplied['message'][0]
['heading'],
);
markers.add(driverAcceptedMarker);
update();
mapController?.animateCamera(CameraUpdate.newLatLng(LatLng(
driverCarsLocationToPassengerAfterApplied[i].latitude,
driverCarsLocationToPassengerAfterApplied[i].longitude)));
update();
} // Update the map with the new markers
// final driverAcceptedMarker = Marker(
// onTap: () => print('marker pressed'),
// infoWindow: InfoWindow(
// title:
// '${driverCarsLocationToPassengerAfterApplied[i].latitude} minutes'),
// markerId: MarkerId(
// datadriverCarsLocationToPassengerAfterApplied['message'][0]['id']
// .toString()),
// position: LatLng(driverCarsLocationToPassengerAfterApplied[i].latitude,
// driverCarsLocationToPassengerAfterApplied[i].longitude),
// rotation: datadriverCarsLocationToPassengerAfterApplied['message'][0]
// ['heading'],
// );
// markers.add(driverAcceptedMarker);
// update();
mapController?.animateCamera(CameraUpdate.newLatLng(LatLng(
driverCarsLocationToPassengerAfterApplied[0].latitude,
driverCarsLocationToPassengerAfterApplied[0].longitude)));
update();
// } // Update the map with the new markers
}
restCounter() {