|
|
|
|
@@ -23,6 +23,7 @@ import '../../views/widgets/elevated_btn.dart';
|
|
|
|
|
import '../firebase/firbase_messge.dart';
|
|
|
|
|
import '../functions/crud.dart';
|
|
|
|
|
import '../functions/launch.dart';
|
|
|
|
|
import '../functions/location_controller.dart';
|
|
|
|
|
import '../functions/secure_storage.dart';
|
|
|
|
|
import '../payment/payment_controller.dart';
|
|
|
|
|
|
|
|
|
|
@@ -59,7 +60,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
LatLngBounds? boundsdata;
|
|
|
|
|
List<Marker> markers = [];
|
|
|
|
|
List<Polyline> polyLines = [];
|
|
|
|
|
late LatLng myLocation;
|
|
|
|
|
late LatLng passengerLocation = const LatLng(32, 34);
|
|
|
|
|
late LatLng newMyLocation = const LatLng(32.115295, 36.064773);
|
|
|
|
|
late LatLng newStartPointLocation = const LatLng(32.115295, 36.064773);
|
|
|
|
|
late LatLng newPointLocation0 = const LatLng(32.115295, 36.064773);
|
|
|
|
|
@@ -205,8 +206,8 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
currentLocationToFormPlaces = true;
|
|
|
|
|
currentLocationString = 'Waiting for your location'.tr;
|
|
|
|
|
await getLocation();
|
|
|
|
|
currentLocationString = myLocation.toString();
|
|
|
|
|
newStartPointLocation = myLocation;
|
|
|
|
|
currentLocationString = passengerLocation.toString();
|
|
|
|
|
newStartPointLocation = passengerLocation;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -215,6 +216,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
clearPolyline();
|
|
|
|
|
isWayPointStopsSheetUtilGetMap = false;
|
|
|
|
|
durationToRide = 0;
|
|
|
|
|
distanceOfDestnation = 0;
|
|
|
|
|
wayPointSheetHeight = 0;
|
|
|
|
|
for (var i = 0; i < Get.find<WayPointController>().wayPoints.length; i++) {
|
|
|
|
|
if (placesCoordinate[i + 1].toString() != '') {
|
|
|
|
|
@@ -374,7 +376,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
// Format the message.
|
|
|
|
|
String message =
|
|
|
|
|
'Hi! This is ${box.read(BoxName.name)}. I am using ${box.read(AppInformation.appName)} to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} is driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()} with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}. I am currently located at $myLocation. If you need to reach me, please contact the driver directly at $driverPhone.';
|
|
|
|
|
'Hi! This is ${box.read(BoxName.name)}. I am using ${box.read(AppInformation.appName)} to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} is driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()} with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}. I am currently located at $passengerLocation. If you need to reach me, please contact the driver directly at $driverPhone.';
|
|
|
|
|
|
|
|
|
|
// Launch the URL to send the SMS.
|
|
|
|
|
launchCommunication('sms', to, message);
|
|
|
|
|
@@ -387,7 +389,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
// Format the message.
|
|
|
|
|
String message =
|
|
|
|
|
'Hi! This is ${box.read(BoxName.name)}.\n I am using ${box.read(AppInformation.appName)} to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} \nis driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()}\n with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}.\n I am currently located at $myLocation.\n If you need to reach me, please contact the driver directly at\n\n $driverPhone.';
|
|
|
|
|
'Hi! This is ${box.read(BoxName.name)}.\n I am using ${box.read(AppInformation.appName)} to ride with ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} as the driver. ${dataCarsLocationByPassenger['message'][carsOrder]['first_name'].toString()} \nis driving a ${dataCarsLocationByPassenger['message'][carsOrder]['model'].toString()}\n with license plate ${dataCarsLocationByPassenger['message'][carsOrder]['license_plate'].toString()}.\n I am currently located at $passengerLocation.\n If you need to reach me, please contact the driver directly at\n\n $driverPhone.';
|
|
|
|
|
|
|
|
|
|
// Launch the URL to send the SMS.
|
|
|
|
|
launchCommunication('whatsapp', to, message);
|
|
|
|
|
@@ -727,8 +729,8 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
Future getCarsLocationByPassenger() async {
|
|
|
|
|
// if (rideConfirm == false) {
|
|
|
|
|
carsLocationByPassenger = [];
|
|
|
|
|
LatLngBounds bounds =
|
|
|
|
|
calculateBounds(myLocation.latitude, myLocation.longitude, 8000);
|
|
|
|
|
LatLngBounds bounds = calculateBounds(
|
|
|
|
|
passengerLocation.latitude, passengerLocation.longitude, 8000);
|
|
|
|
|
print(
|
|
|
|
|
'Southwest: ${bounds.southwest.latitude}, ${bounds.southwest.longitude}');
|
|
|
|
|
print(
|
|
|
|
|
@@ -852,7 +854,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
shouldFetch = false;
|
|
|
|
|
isPassengerChosen = false;
|
|
|
|
|
isCashConfirmPageShown = false;
|
|
|
|
|
totalStepDurations = 0;
|
|
|
|
|
// totalStepDurations = 0;
|
|
|
|
|
isCashSelectedBeforeConfirmRide = false;
|
|
|
|
|
timeToPassengerFromDriverAfterApplied = 0;
|
|
|
|
|
changeCancelRidePageShow();
|
|
|
|
|
@@ -883,7 +885,9 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
isPassengerChosen = false;
|
|
|
|
|
isCashSelectedBeforeConfirmRide = false;
|
|
|
|
|
isPickerShown = false;
|
|
|
|
|
totalStepDurations = 0;
|
|
|
|
|
haveSteps = false;
|
|
|
|
|
isMarkersShown = false;
|
|
|
|
|
// totalStepDurations = 0;
|
|
|
|
|
timeToPassengerFromDriverAfterApplied = 0;
|
|
|
|
|
update();
|
|
|
|
|
} else {
|
|
|
|
|
@@ -900,10 +904,12 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
rideConfirm = false;
|
|
|
|
|
shouldFetch = false;
|
|
|
|
|
isPassengerChosen = false;
|
|
|
|
|
haveSteps = false;
|
|
|
|
|
isMarkersShown = false;
|
|
|
|
|
isCashConfirmPageShown = false;
|
|
|
|
|
isCashSelectedBeforeConfirmRide = false;
|
|
|
|
|
timeToPassengerFromDriverAfterApplied = 0;
|
|
|
|
|
totalStepDurations = 0;
|
|
|
|
|
// totalStepDurations = 0;
|
|
|
|
|
changeCancelRidePageShow();
|
|
|
|
|
clearPolyline();
|
|
|
|
|
remainingTime = 0;
|
|
|
|
|
@@ -1040,7 +1046,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
Future getPlaces() async {
|
|
|
|
|
var url =
|
|
|
|
|
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${AK.mapAPIKEY}';
|
|
|
|
|
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeDestinationController.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
|
|
|
|
|
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeDestinationController.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
|
|
|
|
|
|
|
|
|
|
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
|
|
|
|
|
|
|
|
|
@@ -1052,7 +1058,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
Future getPlacesStart() async {
|
|
|
|
|
var url =
|
|
|
|
|
// '${AppLink.googleMapsLink}place/nearbysearch/json?location=${mylocation.longitude}&radius=25000&language=ar&keyword=&key=${placeController.text}${AK.mapAPIKEY}';
|
|
|
|
|
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeStartController.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
|
|
|
|
|
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${placeStartController.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
|
|
|
|
|
|
|
|
|
|
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
|
|
|
|
|
|
|
|
|
@@ -1063,7 +1069,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
Future getPlacesListsWayPoint(int index) async {
|
|
|
|
|
var url =
|
|
|
|
|
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint0Controller.text}&location=${myLocation.latitude},${myLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
|
|
|
|
|
'${AppLink.googleMapsLink}place/nearbysearch/json?keyword=${wayPoint0Controller.text}&location=${passengerLocation.latitude},${passengerLocation.longitude}&radius=50000&language=en&key=${AK.mapAPIKEY.toString()}';
|
|
|
|
|
|
|
|
|
|
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
|
|
|
|
|
|
|
|
|
@@ -1176,7 +1182,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
// Get the current location
|
|
|
|
|
LocationData _locationData = await location.getLocation();
|
|
|
|
|
myLocation =
|
|
|
|
|
passengerLocation =
|
|
|
|
|
(_locationData.latitude != null && _locationData.longitude != null
|
|
|
|
|
? LatLng(_locationData.latitude!, _locationData.longitude!)
|
|
|
|
|
: null)!;
|
|
|
|
|
@@ -1209,10 +1215,12 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
GoogleMapController? mapController;
|
|
|
|
|
void onMapCreated(GoogleMapController controller) {
|
|
|
|
|
// myLocation = Get.find<LocationController>().location as LatLng;
|
|
|
|
|
// myLocation = myLocation;
|
|
|
|
|
mapController = controller;
|
|
|
|
|
controller.getVisibleRegion();
|
|
|
|
|
controller.animateCamera(
|
|
|
|
|
CameraUpdate.newLatLng(myLocation),
|
|
|
|
|
CameraUpdate.newLatLng(passengerLocation),
|
|
|
|
|
);
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
@@ -1275,7 +1283,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
// Update the map with the new markers
|
|
|
|
|
mapController?.animateCamera(CameraUpdate.newLatLng(
|
|
|
|
|
LatLng(myLocation.latitude, myLocation.longitude)));
|
|
|
|
|
LatLng(passengerLocation.latitude, passengerLocation.longitude)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String durationByPassenger = '';
|
|
|
|
|
@@ -1288,71 +1296,74 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
if (polyLines.isEmpty || data.isEmpty) {
|
|
|
|
|
if (rideConfirm == false) {
|
|
|
|
|
double nearestDistance = double.infinity;
|
|
|
|
|
if (dataCarsLocationByPassenger['message'].length > 0) {
|
|
|
|
|
for (var i = 0;
|
|
|
|
|
i < dataCarsLocationByPassenger['message'].length;
|
|
|
|
|
i++) {
|
|
|
|
|
var carLocation = dataCarsLocationByPassenger['message'][i];
|
|
|
|
|
if (dataCarsLocationByPassenger != 'failure') {
|
|
|
|
|
if (dataCarsLocationByPassenger['message'].length > 0) {
|
|
|
|
|
for (var i = 0;
|
|
|
|
|
i < dataCarsLocationByPassenger['message'].length;
|
|
|
|
|
i++) {
|
|
|
|
|
var carLocation = dataCarsLocationByPassenger['message'][i];
|
|
|
|
|
|
|
|
|
|
// double distance1 = Geolocator.distanceBetween(
|
|
|
|
|
// mylocation.latitude,
|
|
|
|
|
// mylocation.longitude,
|
|
|
|
|
// double.parse(carLocation['latitude']),
|
|
|
|
|
// double.parse(carLocation['longitude']),
|
|
|
|
|
// );
|
|
|
|
|
// if (distance1 < nearestDistance) {
|
|
|
|
|
// nearestDistance = distance1;
|
|
|
|
|
// // nearestCarLocation = carLocation;
|
|
|
|
|
// nearestCar = CarLocation(
|
|
|
|
|
// distance: distance1,
|
|
|
|
|
// id: carLocation['driver_id'],
|
|
|
|
|
// latitude: double.parse(carLocation['latitude']),
|
|
|
|
|
// longitude: double.parse(carLocation['longitude']),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// isloading = true;
|
|
|
|
|
update();
|
|
|
|
|
// Make API request to get exact distance and duration
|
|
|
|
|
String apiUrl =
|
|
|
|
|
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${myLocation.latitude},${myLocation.longitude}&units=metric&key=${AK.mapAPIKEY}';
|
|
|
|
|
var response = await CRUD().getGoogleApi(link: apiUrl, payload: {});
|
|
|
|
|
if (response['status'] == "OK") {
|
|
|
|
|
var data = response;
|
|
|
|
|
// Extract distance and duration from the response and handle accordingly
|
|
|
|
|
int distance1 =
|
|
|
|
|
data['rows'][0]['elements'][0]['distance']['value'];
|
|
|
|
|
distanceByPassenger =
|
|
|
|
|
data['rows'][0]['elements'][0]['distance']['text'];
|
|
|
|
|
duration1 = data['rows'][0]['elements'][0]['duration']['value'];
|
|
|
|
|
|
|
|
|
|
durationFromDriverToPassenger =
|
|
|
|
|
Duration(seconds: duration1.toInt());
|
|
|
|
|
newTime1 = currentTime.add(durationFromDriverToPassenger);
|
|
|
|
|
timeFromDriverToPassenger =
|
|
|
|
|
newTime1.add(Duration(minutes: 2.toInt()));
|
|
|
|
|
durationByPassenger =
|
|
|
|
|
data['rows'][0]['elements'][0]['duration']['text'];
|
|
|
|
|
// double distance1 = Geolocator.distanceBetween(
|
|
|
|
|
// mylocation.latitude,
|
|
|
|
|
// mylocation.longitude,
|
|
|
|
|
// double.parse(carLocation['latitude']),
|
|
|
|
|
// double.parse(carLocation['longitude']),
|
|
|
|
|
// );
|
|
|
|
|
// if (distance1 < nearestDistance) {
|
|
|
|
|
// nearestDistance = distance1;
|
|
|
|
|
// // nearestCarLocation = carLocation;
|
|
|
|
|
// nearestCar = CarLocation(
|
|
|
|
|
// distance: distance1,
|
|
|
|
|
// id: carLocation['driver_id'],
|
|
|
|
|
// latitude: double.parse(carLocation['latitude']),
|
|
|
|
|
// longitude: double.parse(carLocation['longitude']),
|
|
|
|
|
// );
|
|
|
|
|
// }
|
|
|
|
|
// isloading = true;
|
|
|
|
|
update();
|
|
|
|
|
if (distance1 < nearestDistance) {
|
|
|
|
|
nearestDistance = distance1.toDouble();
|
|
|
|
|
// Make API request to get exact distance and duration
|
|
|
|
|
String apiUrl =
|
|
|
|
|
'${AppLink.googleMapsLink}distancematrix/json?destinations=${carLocation['latitude']},${carLocation['longitude']}&origins=${passengerLocation.latitude},${passengerLocation.longitude}&units=metric&key=${AK.mapAPIKEY}';
|
|
|
|
|
var response =
|
|
|
|
|
await CRUD().getGoogleApi(link: apiUrl, payload: {});
|
|
|
|
|
if (response['status'] == "OK") {
|
|
|
|
|
var data = response;
|
|
|
|
|
// Extract distance and duration from the response and handle accordingly
|
|
|
|
|
int distance1 =
|
|
|
|
|
data['rows'][0]['elements'][0]['distance']['value'];
|
|
|
|
|
distanceByPassenger =
|
|
|
|
|
data['rows'][0]['elements'][0]['distance']['text'];
|
|
|
|
|
duration1 = data['rows'][0]['elements'][0]['duration']['value'];
|
|
|
|
|
|
|
|
|
|
nearestCar = CarLocation(
|
|
|
|
|
distance: distance1.toDouble(),
|
|
|
|
|
duration: duration1.toDouble(),
|
|
|
|
|
id: carLocation['driver_id'],
|
|
|
|
|
latitude: double.parse(carLocation['latitude']),
|
|
|
|
|
longitude: double.parse(carLocation['longitude']),
|
|
|
|
|
);
|
|
|
|
|
// isloading = false;
|
|
|
|
|
durationFromDriverToPassenger =
|
|
|
|
|
Duration(seconds: duration1.toInt());
|
|
|
|
|
newTime1 = currentTime.add(durationFromDriverToPassenger);
|
|
|
|
|
timeFromDriverToPassenger =
|
|
|
|
|
newTime1.add(Duration(minutes: 2.toInt()));
|
|
|
|
|
durationByPassenger =
|
|
|
|
|
data['rows'][0]['elements'][0]['duration']['text'];
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (distance1 < nearestDistance) {
|
|
|
|
|
nearestDistance = distance1.toDouble();
|
|
|
|
|
|
|
|
|
|
// Handle the distance and duration as needed
|
|
|
|
|
else {
|
|
|
|
|
print(
|
|
|
|
|
'Failed to retrieve distance and duration: ${response['status']}');
|
|
|
|
|
// Handle the failure case
|
|
|
|
|
nearestCar = CarLocation(
|
|
|
|
|
distance: distance1.toDouble(),
|
|
|
|
|
duration: duration1.toDouble(),
|
|
|
|
|
id: carLocation['driver_id'],
|
|
|
|
|
latitude: double.parse(carLocation['latitude']),
|
|
|
|
|
longitude: double.parse(carLocation['longitude']),
|
|
|
|
|
);
|
|
|
|
|
// isloading = false;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Handle the distance and duration as needed
|
|
|
|
|
else {
|
|
|
|
|
print(
|
|
|
|
|
'Failed to retrieve distance and duration: ${response['status']}');
|
|
|
|
|
// Handle the failure case
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1369,6 +1380,11 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
getMap(String origin, destination) async {
|
|
|
|
|
await getCarsLocationByPassenger();
|
|
|
|
|
// print(carsLocationByPassenger);
|
|
|
|
|
var coordDestination = destination.split(',');
|
|
|
|
|
double latPassengerDestination = double.parse(coordDestination[0]);
|
|
|
|
|
double lngPassengerDestination = double.parse(coordDestination[1]);
|
|
|
|
|
myDestination = LatLng(latPassengerDestination, lngPassengerDestination);
|
|
|
|
|
|
|
|
|
|
isLoading = false;
|
|
|
|
|
update();
|
|
|
|
|
var url =
|
|
|
|
|
@@ -1405,17 +1421,23 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
// Animate the camera to the adjusted bounds
|
|
|
|
|
if (distanceOfDestnation <= 5) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 14));
|
|
|
|
|
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 13));
|
|
|
|
|
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 12));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 12));
|
|
|
|
|
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 11));
|
|
|
|
|
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 10));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 10));
|
|
|
|
|
} else if (distanceOfDestnation >= 100) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newStartPointLocation, 7));
|
|
|
|
|
}
|
|
|
|
|
if (polyLines.isNotEmpty) {
|
|
|
|
|
clearPolyline();
|
|
|
|
|
@@ -1434,25 +1456,30 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int totalStepDurations = 0;
|
|
|
|
|
getMapPoints(String origin, String destination, int index) async {
|
|
|
|
|
double distanceOfDestnation = 0;
|
|
|
|
|
bool haveSteps = false;
|
|
|
|
|
getMapPoints(String originSteps, String destinationSteps, int index) async {
|
|
|
|
|
isWayPointStopsSheetUtilGetMap = false;
|
|
|
|
|
|
|
|
|
|
haveSteps = true;
|
|
|
|
|
await getCarsLocationByPassenger();
|
|
|
|
|
isLoading = false;
|
|
|
|
|
// isLoading = true;
|
|
|
|
|
update();
|
|
|
|
|
var url =
|
|
|
|
|
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
|
|
|
|
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destinationSteps&origin=$originSteps&key=${AK.mapAPIKEY}');
|
|
|
|
|
// print(url);
|
|
|
|
|
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
|
|
|
|
data = response['routes'][0]['legs'];
|
|
|
|
|
// print(data);
|
|
|
|
|
isLoading = false;
|
|
|
|
|
// isLoading = false;
|
|
|
|
|
|
|
|
|
|
int durationToRide0 = data[0]['duration']['value'];
|
|
|
|
|
durationToRide = durationToRide + durationToRide0;
|
|
|
|
|
print('durationToRide is ${data[0]['duration']['value']}');
|
|
|
|
|
print('totalStepDurations is $durationToRide');
|
|
|
|
|
double distanceToRide0 = (data[0]['distance']['value']) / 1000;
|
|
|
|
|
distanceOfDestnation = distanceOfDestnation + distanceToRide0;
|
|
|
|
|
print('distanceToRide is $distanceToRide0');
|
|
|
|
|
print('totalStepdistance is $distanceOfDestnation');
|
|
|
|
|
update();
|
|
|
|
|
final points =
|
|
|
|
|
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
|
|
|
|
@@ -1474,22 +1501,28 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
// Calculate the zoom level based on the distance and screen size
|
|
|
|
|
|
|
|
|
|
double distanceOfDestnation =
|
|
|
|
|
getDistanceFromText(data[0]['distance']['text']);
|
|
|
|
|
// double distanceOfDestnation =
|
|
|
|
|
// getDistanceFromText(data[0]['distance']['text']);
|
|
|
|
|
|
|
|
|
|
// Animate the camera to the adjusted bounds
|
|
|
|
|
if (distanceOfDestnation <= 5) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 15));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 14));
|
|
|
|
|
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 13));
|
|
|
|
|
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 12));
|
|
|
|
|
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 8));
|
|
|
|
|
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 9));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 6));
|
|
|
|
|
} else if (distanceOfDestnation >= 100) {
|
|
|
|
|
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7));
|
|
|
|
|
mapController!
|
|
|
|
|
.animateCamera(CameraUpdate.newLatLngZoom(newPointLocation0, 5));
|
|
|
|
|
}
|
|
|
|
|
if (polyLines.isNotEmpty) {
|
|
|
|
|
// clearPolyline();
|
|
|
|
|
@@ -1503,7 +1536,7 @@ class MapPassengerController extends GetxController {
|
|
|
|
|
|
|
|
|
|
polyLines.add(polyline);
|
|
|
|
|
rideConfirm = false;
|
|
|
|
|
isMarkersShown = true;
|
|
|
|
|
// isMarkersShown = true;
|
|
|
|
|
update();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|