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

View File

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