4/2/8
This commit is contained in:
@@ -56,6 +56,23 @@ class LocationController extends GetxController {
|
||||
print('total point is $totalPoints');
|
||||
|
||||
await getLocation();
|
||||
// Animate camera to user location (optional)
|
||||
if (Get.find<HomeCaptainController>().rideId == 'rideId') {
|
||||
Get.find<MapDriverController>()
|
||||
.mapController!
|
||||
.animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
)));
|
||||
} else {
|
||||
Get.find<HomeCaptainController>()
|
||||
.mapHomeCaptainController
|
||||
.animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
)));
|
||||
}
|
||||
|
||||
// if (box.read(BoxName.driverID) != null) {
|
||||
await CRUD()
|
||||
.post(link: AppLink.addCarsLocationByPassenger, payload: {
|
||||
@@ -71,21 +88,21 @@ class LocationController extends GetxController {
|
||||
: totalDistance.toStringAsFixed(1),
|
||||
'status': box.read(BoxName.statusDriverLocation).toString()
|
||||
});
|
||||
if (Get.find<HomeCaptainController>().rideId == '0') {
|
||||
await sql.insertData({
|
||||
'driver_id': box.read(BoxName.driverID),
|
||||
'latitude': myLocation.latitude.toString(),
|
||||
'longitude': myLocation.longitude.toString(),
|
||||
'created_at': DateTime.now().toString(),
|
||||
}, TableName.carLocations);
|
||||
} else {
|
||||
await sql.insertData({
|
||||
'order_id': Get.find<MapDriverController>().rideId,
|
||||
'created_at': DateTime.now().toString(),
|
||||
'lat': myLocation.latitude.toString(),
|
||||
'lng': myLocation.longitude.toString(),
|
||||
}, TableName.rideLocation);
|
||||
}
|
||||
// if (Get.find<HomeCaptainController>().rideId == '0') {
|
||||
// await sql.insertData({
|
||||
// 'driver_id': box.read(BoxName.driverID),
|
||||
// 'latitude': myLocation.latitude.toString(),
|
||||
// 'longitude': myLocation.longitude.toString(),
|
||||
// 'created_at': DateTime.now().toString(),
|
||||
// }, TableName.carLocations);
|
||||
// } else {
|
||||
// await sql.insertData({
|
||||
// 'order_id': Get.find<MapDriverController>().rideId,
|
||||
// 'created_at': DateTime.now().toString(),
|
||||
// 'lat': myLocation.latitude.toString(),
|
||||
// 'lng': myLocation.longitude.toString(),
|
||||
// }, TableName.rideLocation);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
|
||||
@@ -155,14 +155,14 @@ class HomeCaptainController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
late GoogleMapController mapHomeCaptaiController;
|
||||
late GoogleMapController mapHomeCaptainController;
|
||||
void onMapCreated(GoogleMapController controller) {
|
||||
mapHomeCaptaiController = controller;
|
||||
mapHomeCaptainController = controller;
|
||||
controller.getVisibleRegion();
|
||||
// Animate camera to user location (optional)
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
);
|
||||
update();
|
||||
}
|
||||
|
||||
void savePeriod(Duration period) {
|
||||
@@ -212,7 +212,7 @@ class HomeCaptainController extends GetxController {
|
||||
getCountRideToday();
|
||||
getAllPayment();
|
||||
startPeriodicExecution();
|
||||
onMapCreated(mapHomeCaptaiController);
|
||||
onMapCreated(mapHomeCaptainController);
|
||||
totalPoints = Get.find<CaptainWalletController>().totalPoints;
|
||||
getRefusedOrderByCaptain();
|
||||
// LocationController().getLocation();
|
||||
|
||||
@@ -91,6 +91,7 @@ class MapDriverController extends GetxController {
|
||||
late LatLng myLocation;
|
||||
int remainingTimeTimerRideBegin = 60;
|
||||
String stringRemainingTimeRideBegin = '';
|
||||
String stringRemainingTimeRideBegin1 = '';
|
||||
double progressTimerRideBegin = 0;
|
||||
late Timer timer;
|
||||
String? mapAPIKEY;
|
||||
@@ -104,7 +105,9 @@ class MapDriverController extends GetxController {
|
||||
myLocation = myLocation;
|
||||
mapController = controller;
|
||||
controller.getVisibleRegion();
|
||||
|
||||
controller.animateCamera(
|
||||
CameraUpdate.newLatLng(Get.find<LocationController>().myLocation),
|
||||
);
|
||||
// Set up a timer or interval to trigger the marker update every 3 seconds.
|
||||
timer = Timer.periodic(const Duration(seconds: 1), (_) {
|
||||
updateMarker();
|
||||
@@ -603,7 +606,10 @@ class MapDriverController extends GetxController {
|
||||
int seconds = remainingTimeTimerRideBegin % 60;
|
||||
stringRemainingTimeRideBegin =
|
||||
'$minutes:${seconds.toString().padLeft(2, '0')}';
|
||||
|
||||
int minutes1 = (rideTimerFromBegin / 60).floor();
|
||||
int seconds1 = rideTimerFromBegin % 60;
|
||||
stringRemainingTimeRideBegin1 =
|
||||
'$minutes1:${seconds1.toString().padLeft(2, '0')}';
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ class PassengerLocationMapPage extends StatelessWidget {
|
||||
Get.put(MapDriverController());
|
||||
|
||||
return MyScafolld(
|
||||
title: 'Map Passenger'.tr,
|
||||
title: Get.find<MapDriverController>().carType,
|
||||
body: [
|
||||
GoogleDriverMap(locationController: locationController),
|
||||
const PassengerInfoWindow(),
|
||||
|
||||
@@ -89,7 +89,7 @@ GetBuilder<HomeCaptainController> leftMainMenuCaptainIcons() {
|
||||
borderRadius: BorderRadius.circular(15)),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
controller.mapHomeCaptaiController
|
||||
controller.mapHomeCaptainController
|
||||
.animateCamera(CameraUpdate.newLatLng(LatLng(
|
||||
Get.find<LocationController>().myLocation.latitude,
|
||||
Get.find<LocationController>().myLocation.longitude,
|
||||
|
||||
@@ -62,8 +62,7 @@ GetBuilder<MapDriverController> driverEndRideBar() {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: [
|
||||
const Icon(Icons.timer),
|
||||
Text(mapDriverController.rideTimerFromBegin
|
||||
.toStringAsFixed(0)),
|
||||
Text(mapDriverController.stringRemainingTimeRideBegin1),
|
||||
const Icon(Icons.location_on),
|
||||
Text(
|
||||
'${mapDriverController.recentDistanceToDash.toStringAsFixed(0)} ${'KM'.tr}'),
|
||||
|
||||
@@ -30,7 +30,7 @@ class GoogleDriverMap extends StatelessWidget {
|
||||
),
|
||||
onCameraMoveStarted: () {},
|
||||
onCameraMove: (position) {
|
||||
// locationController.myLocation = position.target;
|
||||
locationController.myLocation = position.target;
|
||||
print(position);
|
||||
},
|
||||
minMaxZoomPreference: const MinMaxZoomPreference(6, 18),
|
||||
|
||||
Reference in New Issue
Block a user