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() {

View File

@@ -143,84 +143,95 @@ class GoogleMapPassengerWidget extends StatelessWidget {
target: controller.passengerLocation,
zoom: 15,
),
markers: {
if (controller.statusRide != 'Apply' ||
!controller.rideTimerBegin)
for (var carLocation in controller.carLocationsModels)
Marker(
// anchor: const Offset(4, 4),
position: LatLng(
carLocation.latitude,
carLocation.longitude,
),
icon: controller.carIcon,
markerId: MarkerId(carLocation.toString()),
rotation: carLocation.heading,
),
// controller.carMarrkerAplied,
if (controller.statusRide == 'Apply')
for (var carLocation
in controller.driverCarsLocationToPassengerAfterApplied)
Marker(
// anchor: const Offset(4, 4),
position: LatLng(
carLocation.latitude,
carLocation.longitude,
), //carLocation,
icon: controller.carIcon,
rotation: double.parse(controller
.datadriverCarsLocationToPassengerAfterApplied[
'message'][0]['heading']),
markerId: MarkerId(controller
.datadriverCarsLocationToPassengerAfterApplied[
'message'][0]['longitude']
.toString())),
for (int i = 1;
i < controller.coordinatesWithoutEmpty.length - 1;
i++)
Marker(
// anchor: const Offset(4, 4),
position: LatLng(
double.parse(controller.coordinatesWithoutEmpty[i]
.split(',')[0]),
double.parse(controller.coordinatesWithoutEmpty[i]
.split(',')[1])),
icon: controller.tripIcon,
markerId: MarkerId(
controller.coordinatesWithoutEmpty[i].toString())),
if (controller.isMarkersShown)
Marker(
markerId: MarkerId('MyLocation'.tr),
position: controller.newStartPointLocation,
draggable: true,
icon: controller.startIcon,
),
if (controller.isMarkersShown)
Marker(
markerId: MarkerId('Destination'.tr),
position: controller.myDestination,
draggable: true,
icon: controller.endIcon,
),
if (controller.haveSteps)
Marker(
markerId: MarkerId('StartSteps'.tr),
position: LatLng(
double.parse(
controller.placesCoordinate[0].split(',')[0]),
double.parse(
controller.placesCoordinate[0].split(',')[1])),
draggable: true,
icon: controller.startIcon,
),
if (controller.haveSteps)
Marker(
markerId: MarkerId('EndSteps'.tr),
position: controller.latestPosition,
draggable: true,
icon: controller.endIcon,
),
},
markers: controller.markers.toSet(),
// {
// if (controller.statusRide != 'Apply' ||
// !controller.rideTimerBegin)
// for (var carLocation in controller.carLocationsModels)
// // Marker(
// // // anchor: const Offset(4, 4),
// // position: LatLng(
// // carLocation.latitude,
// // carLocation.longitude,
// // ),
// // icon: controller.carIcon,
// // markerId: MarkerId(carLocation.toString()),
// // rotation: carLocation.heading,
// // ),
// // controller.carMarrkerAplied,
// if (controller.statusRide == 'Apply')
// // for (var carLocation
// // in controller.driverCarsLocationToPassengerAfterApplied)
// Marker(
// // anchor: const Offset(4, 4),
// position: LatLng(
// double.parse(
// controller
// .datadriverCarsLocationToPassengerAfterApplied[
// 'message'][0]['latitude'],
// ),
// double.parse(
// controller
// .datadriverCarsLocationToPassengerAfterApplied[
// 'message'][0]['longitude'],
// ),
// ), //carLocation,
// icon: controller.carIcon,
// rotation: double.parse(controller
// .datadriverCarsLocationToPassengerAfterApplied[
// 'message'][0]['heading']),
// markerId: MarkerId(controller
// .datadriverCarsLocationToPassengerAfterApplied[
// 'message'][0]['longitude']
// .toString())),
// for (int i = 1;
// i < controller.coordinatesWithoutEmpty.length - 1;
// i++)
// Marker(
// // anchor: const Offset(4, 4),
// position: LatLng(
// double.parse(controller.coordinatesWithoutEmpty[i]
// .split(',')[0]),
// double.parse(controller.coordinatesWithoutEmpty[i]
// .split(',')[1])),
// icon: controller.tripIcon,
// markerId: MarkerId(
// controller.coordinatesWithoutEmpty[i].toString())),
// if (controller.isMarkersShown)
// Marker(
// markerId: MarkerId('MyLocation'.tr),
// position: controller.newStartPointLocation,
// draggable: true,
// icon: controller.startIcon,
// ),
// if (controller.isMarkersShown)
// Marker(
// markerId: MarkerId('Destination'.tr),
// position: controller.myDestination,
// draggable: true,
// icon: controller.endIcon,
// ),
// if (controller.haveSteps)
// Marker(
// markerId: MarkerId('StartSteps'.tr),
// position: LatLng(
// double.parse(
// controller.placesCoordinate[0].split(',')[0]),
// double.parse(
// controller.placesCoordinate[0].split(',')[1])),
// draggable: true,
// icon: controller.startIcon,
// ),
// if (controller.haveSteps)
// Marker(
// markerId: MarkerId('EndSteps'.tr),
// position: controller.latestPosition,
// draggable: true,
// icon: controller.endIcon,
// ),
// },
polylines: {
Polyline(
zIndex: 2,