2/6/1
This commit is contained in:
@@ -212,6 +212,7 @@ class MapPassengerController extends GetxController {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> coordinatesWithoutEmpty = [];
|
||||||
void getMapPointsForAllMethods() async {
|
void getMapPointsForAllMethods() async {
|
||||||
print(placesCoordinate.toString());
|
print(placesCoordinate.toString());
|
||||||
clearPolyline();
|
clearPolyline();
|
||||||
@@ -221,16 +222,24 @@ class MapPassengerController extends GetxController {
|
|||||||
distanceOfDestnation = 0;
|
distanceOfDestnation = 0;
|
||||||
wayPointSheetHeight = 0;
|
wayPointSheetHeight = 0;
|
||||||
haveSteps = true;
|
haveSteps = true;
|
||||||
for (var i = 0; i < Get.find<WayPointController>().wayPoints.length; i++) {
|
|
||||||
if (placesCoordinate[i + 1].toString() != '') {
|
// Filter out empty value
|
||||||
|
coordinatesWithoutEmpty =
|
||||||
|
placesCoordinate.where((coord) => coord.isNotEmpty).toList();
|
||||||
|
latestPosition = LatLng(
|
||||||
|
double.parse(coordinatesWithoutEmpty.last.split(',')[0]),
|
||||||
|
double.parse(coordinatesWithoutEmpty.last.split(',')[1]));
|
||||||
|
// print(coordinatesWithoutEmpty);
|
||||||
|
for (var i = 0; i < coordinatesWithoutEmpty.length; i++) {
|
||||||
|
if ((i + 1) < coordinatesWithoutEmpty.length) {
|
||||||
await getMapPoints(
|
await getMapPoints(
|
||||||
placesCoordinate[i].toString(),
|
coordinatesWithoutEmpty[i].toString(),
|
||||||
placesCoordinate[i + 1].toString(),
|
coordinatesWithoutEmpty[i + 1].toString(),
|
||||||
i,
|
i,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateCameraForDistanceAfterGetMap();
|
|
||||||
// isWayPointStopsSheet = false;
|
// isWayPointStopsSheet = false;
|
||||||
if (haveSteps) {
|
if (haveSteps) {
|
||||||
String latestWaypoint =
|
String latestWaypoint =
|
||||||
@@ -240,9 +249,11 @@ class MapPassengerController extends GetxController {
|
|||||||
double.parse(latestWaypoint.split(',')[1]),
|
double.parse(latestWaypoint.split(',')[1]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
updateCameraForDistanceAfterGetMap();
|
||||||
changeWayPointStopsSheet();
|
changeWayPointStopsSheet();
|
||||||
bottomSheet();
|
bottomSheet();
|
||||||
showBottomSheet1();
|
showBottomSheet1();
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1207,11 +1218,7 @@ class MapPassengerController extends GetxController {
|
|||||||
|
|
||||||
void addCustomCarIcon() {
|
void addCustomCarIcon() {
|
||||||
ImageConfiguration config = ImageConfiguration(
|
ImageConfiguration config = ImageConfiguration(
|
||||||
// size: Size(Get.width * .6, Get.height * .6),
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||||
size: const Size(30, 30),
|
|
||||||
devicePixelRatio: Get.pixelRatio
|
|
||||||
// scale: 1.0,
|
|
||||||
);
|
|
||||||
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png',
|
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png',
|
||||||
mipmaps: false)
|
mipmaps: false)
|
||||||
.then((value) {
|
.then((value) {
|
||||||
@@ -1220,6 +1227,17 @@ class MapPassengerController extends GetxController {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addCustomStepIcon() {
|
||||||
|
ImageConfiguration config = ImageConfiguration(
|
||||||
|
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
|
||||||
|
BitmapDescriptor.fromAssetImage(config, 'assets/images/brand.png',
|
||||||
|
mipmaps: false)
|
||||||
|
.then((value) {
|
||||||
|
tripIcon = value;
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> getLocation() async {
|
Future<void> getLocation() async {
|
||||||
isLoading = true;
|
isLoading = true;
|
||||||
update();
|
update();
|
||||||
@@ -1512,7 +1530,64 @@ class MapPassengerController extends GetxController {
|
|||||||
|
|
||||||
double distanceOfDestnation = 0;
|
double distanceOfDestnation = 0;
|
||||||
bool haveSteps = false;
|
bool haveSteps = false;
|
||||||
late LatLng latestPosition = LatLng(0, 0);
|
late LatLng latestPosition;
|
||||||
|
// getMapPoints(String originSteps, String destinationSteps, int index) async {
|
||||||
|
// isWayPointStopsSheetUtilGetMap = false;
|
||||||
|
// haveSteps = true;
|
||||||
|
// await getCarsLocationByPassenger();
|
||||||
|
// // isLoading = true;
|
||||||
|
// update();
|
||||||
|
// String url = '${AppLink.googleMapsLink}directions/json'
|
||||||
|
// '?origin=${coordinatesWithoutEmpty.first}'
|
||||||
|
// '&destination=${coordinatesWithoutEmpty.last}';
|
||||||
|
// if (coordinatesWithoutEmpty.length > 2) {
|
||||||
|
// String waypoints = "";
|
||||||
|
// for (int i = 1; i < coordinatesWithoutEmpty.length - 1; i++) {
|
||||||
|
// waypoints += "${coordinatesWithoutEmpty[i]}|";
|
||||||
|
// }
|
||||||
|
// waypoints = waypoints.substring(0, waypoints.length - 1);
|
||||||
|
// url += "&waypoints=$waypoints";
|
||||||
|
// }
|
||||||
|
// url += '&language=en'
|
||||||
|
// '&avoid=tolls|ferries'
|
||||||
|
// '&key=${AK.mapAPIKEY}';
|
||||||
|
// var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||||
|
// data = response['routes'][0]['legs'];
|
||||||
|
// // //print(data);
|
||||||
|
// // isLoading = false;
|
||||||
|
// int durationToRide0 = data[0]['duration']['value'];
|
||||||
|
// durationToRide = durationToRide + durationToRide0;
|
||||||
|
// print(durationToRide0);
|
||||||
|
// print('durationToRide = $durationToRide');
|
||||||
|
// distance = distanceOfDestnation + (data[0]['distance']['value']) / 1000;
|
||||||
|
// update();
|
||||||
|
// final points =
|
||||||
|
// decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||||
|
// for (int i = 0; i < points.length; i++) {
|
||||||
|
// if (points[i][0].toString() != '') {
|
||||||
|
// double lat = points[i][0].toDouble();
|
||||||
|
// double lng = points[i][1].toDouble();
|
||||||
|
// polylineCoordinatesPointsAll[index].add(LatLng(lat, lng));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // Define the northeast and southwest coordinates
|
||||||
|
// update();
|
||||||
|
// if (polyLines.isNotEmpty) {
|
||||||
|
// // clearPolyline();
|
||||||
|
// } else {
|
||||||
|
// var polyline = Polyline(
|
||||||
|
// polylineId: PolylineId(response["routes"][0]["summary"]),
|
||||||
|
// points: polylineCoordinatesPointsAll[index],
|
||||||
|
// width: 10,
|
||||||
|
// color: Colors.blue,
|
||||||
|
// );
|
||||||
|
// polyLines.add(polyline);
|
||||||
|
// rideConfirm = false;
|
||||||
|
// // isMarkersShown = true;
|
||||||
|
// update();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
getMapPoints(String originSteps, String destinationSteps, int index) async {
|
getMapPoints(String originSteps, String destinationSteps, int index) async {
|
||||||
isWayPointStopsSheetUtilGetMap = false;
|
isWayPointStopsSheetUtilGetMap = false;
|
||||||
// haveSteps = true;
|
// haveSteps = true;
|
||||||
@@ -1529,7 +1604,10 @@ class MapPassengerController extends GetxController {
|
|||||||
|
|
||||||
int durationToRide0 = data[0]['duration']['value'];
|
int durationToRide0 = data[0]['duration']['value'];
|
||||||
durationToRide = durationToRide + durationToRide0;
|
durationToRide = durationToRide + durationToRide0;
|
||||||
|
print(durationToRide0);
|
||||||
|
print('durationToRide = $durationToRide');
|
||||||
distance = distanceOfDestnation + (data[0]['distance']['value']) / 1000;
|
distance = distanceOfDestnation + (data[0]['distance']['value']) / 1000;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
final points =
|
final points =
|
||||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||||
@@ -1560,22 +1638,35 @@ class MapPassengerController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateCameraForDistanceAfterGetMap() {
|
void updateCameraForDistanceAfterGetMap() {
|
||||||
// Get the non-empty values from the data list
|
LatLng coord1 = LatLng(
|
||||||
List<LatLng> nonEmptyValues = data
|
double.parse(coordinatesWithoutEmpty.first.split(',')[0]),
|
||||||
.where((element) => element != null && element.isNotEmpty)
|
double.parse(coordinatesWithoutEmpty.first.split(',')[1]));
|
||||||
.map((element) => LatLng(element['lat'], element['lng']))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
// Define the northeast and southwest coordinates
|
LatLng coord2 = LatLng(
|
||||||
LatLng northeast = nonEmptyValues.first;
|
double.parse(coordinatesWithoutEmpty.last.split(',')[0]),
|
||||||
LatLng southwest = nonEmptyValues.last;
|
double.parse(coordinatesWithoutEmpty.last.split(',')[1]));
|
||||||
|
|
||||||
|
LatLng northeast;
|
||||||
|
LatLng southwest;
|
||||||
|
|
||||||
|
if (coord1.latitude > coord2.latitude) {
|
||||||
|
northeast = coord1;
|
||||||
|
southwest = coord2;
|
||||||
|
} else {
|
||||||
|
northeast = coord2;
|
||||||
|
southwest = coord1;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the LatLngBounds object
|
// Create the LatLngBounds object
|
||||||
LatLngBounds bounds =
|
LatLngBounds bounds =
|
||||||
LatLngBounds(northeast: northeast, southwest: southwest);
|
LatLngBounds(northeast: northeast, southwest: southwest);
|
||||||
|
|
||||||
|
print('boundsbounds');
|
||||||
|
print(bounds);
|
||||||
|
print('boundsbounds');
|
||||||
|
|
||||||
// Fit the camera to the bounds
|
// Fit the camera to the bounds
|
||||||
var cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 130);
|
var cameraUpdate = CameraUpdate.newLatLngBounds(bounds, 160);
|
||||||
mapController!.animateCamera(cameraUpdate);
|
mapController!.animateCamera(cameraUpdate);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -1614,6 +1705,8 @@ class MapPassengerController extends GetxController {
|
|||||||
var firstElement = decode["message"][0];
|
var firstElement = decode["message"][0];
|
||||||
totalPassenger = totalPassenger -
|
totalPassenger = totalPassenger -
|
||||||
(totalPassenger * int.parse(firstElement['amount']) / 100);
|
(totalPassenger * int.parse(firstElement['amount']) / 100);
|
||||||
|
totalDriver = totalDriver -
|
||||||
|
(totalDriver * int.parse(firstElement['amount']) / 100);
|
||||||
promoTaken = true;
|
promoTaken = true;
|
||||||
update();
|
update();
|
||||||
//print(totalPassenger);
|
//print(totalPassenger);
|
||||||
@@ -1635,13 +1728,15 @@ class MapPassengerController extends GetxController {
|
|||||||
Future bottomSheet() async {
|
Future bottomSheet() async {
|
||||||
if (data.isNotEmpty) {
|
if (data.isNotEmpty) {
|
||||||
durationToAdd = Duration(seconds: durationToRide);
|
durationToAdd = Duration(seconds: durationToRide);
|
||||||
//print('durationToRide----- $durationToRide');
|
print('durationToRide----- $durationToRide');
|
||||||
|
print('durationToAdd----- $durationToAdd');
|
||||||
hours = durationToAdd.inHours;
|
hours = durationToAdd.inHours;
|
||||||
minutes = (durationToAdd.inMinutes % 60).round();
|
minutes = (durationToAdd.inMinutes % 60).round();
|
||||||
DateTime currentTime = DateTime.now();
|
DateTime currentTime = DateTime.now();
|
||||||
newTime = currentTime.add(durationToAdd);
|
newTime = currentTime.add(durationToAdd);
|
||||||
averageDuration = (durationToRide / 60) / distance;
|
averageDuration = (durationToRide / 60) / distance;
|
||||||
costDuration = (durationToRide / 60) * averageDuration * 0.016;
|
costDuration = (durationToRide / 60) * averageDuration * 0.016;
|
||||||
|
print('costDuration----- $costDuration');
|
||||||
var totalDriver1 = cost + costDuration;
|
var totalDriver1 = cost + costDuration;
|
||||||
totalPassenger = totalDriver1 + (totalDriver1 * .16);
|
totalPassenger = totalDriver1 + (totalDriver1 * .16);
|
||||||
totalDriver = totalDriver1 + (totalDriver1 * .16);
|
totalDriver = totalDriver1 + (totalDriver1 * .16);
|
||||||
@@ -1766,6 +1861,7 @@ class MapPassengerController extends GetxController {
|
|||||||
getNearestDriverByPassengerLocation();
|
getNearestDriverByPassengerLocation();
|
||||||
addCustomPicker();
|
addCustomPicker();
|
||||||
addCustomCarIcon();
|
addCustomCarIcon();
|
||||||
|
addCustomStepIcon();
|
||||||
addCustomStartIcon();
|
addCustomStartIcon();
|
||||||
addCustomEndIcon();
|
addCustomEndIcon();
|
||||||
startMarkerReloading();
|
startMarkerReloading();
|
||||||
|
|||||||
@@ -15,13 +15,9 @@ GetBuilder<MapDriverController> driverEndRideBar() {
|
|||||||
right: 5,
|
right: 5,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: AppStyle.boxDecoration,
|
decoration: AppStyle.boxDecoration,
|
||||||
<<<<<<< HEAD
|
|
||||||
height: mapDriverController.remainingTimeTimerRideBegin < 60
|
height: mapDriverController.remainingTimeTimerRideBegin < 60
|
||||||
? mapDriverController.driverEndPage = 160
|
? mapDriverController.driverEndPage = 160
|
||||||
: 100,
|
: 100,
|
||||||
=======
|
|
||||||
height: mapDriverController.remainingTimeTimerRideBegin >60?100:160,,
|
|
||||||
>>>>>>> d948723751895f2cb5ff51597ece9bc2fe6c456f
|
|
||||||
width: 200,
|
width: 200,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -148,6 +148,19 @@ class GoogleMapPassengerWidget extends StatelessWidget {
|
|||||||
position: carLocation,
|
position: carLocation,
|
||||||
icon: controller.carIcon,
|
icon: controller.carIcon,
|
||||||
markerId: MarkerId(carLocation.toString())),
|
markerId: MarkerId(carLocation.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)
|
if (controller.isMarkersShown)
|
||||||
Marker(
|
Marker(
|
||||||
markerId: MarkerId('MyLocation'.tr),
|
markerId: MarkerId('MyLocation'.tr),
|
||||||
|
|||||||
Reference in New Issue
Block a user