1/10/1
This commit is contained in:
@@ -49,10 +49,10 @@ class MapPassengerController extends GetxController {
|
||||
List<List<dynamic>> placeListResponseAll = [];
|
||||
|
||||
List<Widget> placeListResponse = [
|
||||
formSearchPlaces1(),
|
||||
formSearchPlaces2(),
|
||||
formSearchPlaces3(),
|
||||
formSearchPlaces4(),
|
||||
formSearchPlaces(0),
|
||||
formSearchPlaces(1),
|
||||
formSearchPlaces(2),
|
||||
formSearchPlaces(3),
|
||||
];
|
||||
LatLngBounds? boundsdata;
|
||||
List<Marker> markers = [];
|
||||
@@ -67,6 +67,12 @@ class MapPassengerController extends GetxController {
|
||||
late LatLng newPointLocation4 = const LatLng(32.115295, 36.064773);
|
||||
LatLng myDestination = const LatLng(32.115295, 36.064773);
|
||||
final List<LatLng> polylineCoordinates = [];
|
||||
final List<LatLng> polylineCoordinates0 = [];
|
||||
final List<LatLng> polylineCoordinates1 = [];
|
||||
final List<LatLng> polylineCoordinates2 = [];
|
||||
final List<LatLng> polylineCoordinates3 = [];
|
||||
final List<LatLng> polylineCoordinates4 = [];
|
||||
List<List<LatLng>> polylineCoordinatesPointsAll = [];
|
||||
List<LatLng> carsLocationByPassenger = [];
|
||||
List<LatLng> driverCarsLocationToPassengerAfterApplied = [];
|
||||
BitmapDescriptor markerIcon = BitmapDescriptor.defaultMarker;
|
||||
@@ -88,6 +94,7 @@ class MapPassengerController extends GetxController {
|
||||
bool startLocationFromMap2 = false;
|
||||
bool startLocationFromMap3 = false;
|
||||
bool startLocationFromMap4 = false;
|
||||
List startLocationFromMapAll = [];
|
||||
bool heightMenuBool = false;
|
||||
bool isPickerShown = false;
|
||||
bool isPointsPageForRider = false;
|
||||
@@ -135,11 +142,18 @@ class MapPassengerController extends GetxController {
|
||||
String hintTextwayPoint4 = 'Search for waypoint'.tr;
|
||||
String currentLocationString = 'Current Location'.tr;
|
||||
String currentLocationString0 = 'Current Location'.tr;
|
||||
String currentLocationString1 = 'Current Location 1'.tr;
|
||||
String currentLocationString2 = 'Current Location 2'.tr;
|
||||
String currentLocationString3 = 'Current Location 3'.tr;
|
||||
String currentLocationString4 = 'Current Location 4'.tr;
|
||||
String currentLocationString1 = 'Add Location 1'.tr;
|
||||
String currentLocationString2 = 'Add Location 2'.tr;
|
||||
String currentLocationString3 = 'Add Location 3'.tr;
|
||||
String currentLocationString4 = 'Add Location 4'.tr;
|
||||
String placesCoordinate0 = ''.tr;
|
||||
String placesCoordinate1 = ''.tr;
|
||||
String placesCoordinate2 = ''.tr;
|
||||
String placesCoordinate3 = ''.tr;
|
||||
String placesCoordinate4 = ''.tr;
|
||||
List<String> currentLocationStringAll = [];
|
||||
List<String> hintTextwayPointStringAll = [];
|
||||
var placesCoordinate = <String>[];
|
||||
String hintTextDestinationPoint = 'Search for your destination'.tr;
|
||||
late String rideId;
|
||||
bool noCarString = false;
|
||||
@@ -151,6 +165,7 @@ class MapPassengerController extends GetxController {
|
||||
bool currentLocationToFormPlaces2 = false;
|
||||
bool currentLocationToFormPlaces3 = false;
|
||||
bool currentLocationToFormPlaces4 = false;
|
||||
List currentLocationToFormPlacesAll = [];
|
||||
late String driverToken;
|
||||
int carsOrder = 0;
|
||||
String? mapAPIKEY;
|
||||
@@ -199,17 +214,23 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
void convertHintTextPlaces0(int index) {
|
||||
if (wayPoint0.isEmpty) {
|
||||
hintTextwayPoint0 = 'Search for your Start point'.tr;
|
||||
void convertHintTextPlaces(int index, var res) {
|
||||
if (placeListResponseAll[index].isEmpty) {
|
||||
placeListResponseAll[index] = res;
|
||||
hintTextwayPointStringAll[index] = 'Search for your Start point'.tr;
|
||||
update();
|
||||
} else {
|
||||
hintTextwayPoint0 = wayPoint0[index]['name'];
|
||||
currentLocationString0 = wayPoint1[index]['name'];
|
||||
double lat = wayPoint0[index]['geometry']['location']['lat'];
|
||||
double lng = wayPoint0[index]['geometry']['location']['lng'];
|
||||
newPointLocation0 = LatLng(lat, lng);
|
||||
hintTextwayPointStringAll[index] = res['name'];
|
||||
currentLocationStringAll[index] = res['name'];
|
||||
placesCoordinate[index] =
|
||||
'${res['geometry']['location']['lat']},${res['geometry']['location']['lng']}';
|
||||
placeListResponseAll[index] = [];
|
||||
allTextEditingPlaces[index].clear();
|
||||
// double lat = wayPoint0[index]['geometry']['location']['lat'];
|
||||
// double lng = wayPoint0[index]['geometry']['location']['lng'];
|
||||
// newPointLocation0 = LatLng(lat, lng);
|
||||
update();
|
||||
Get.back();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -451,9 +472,9 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
void clearPlaces0() {
|
||||
wayPoint0 = [];
|
||||
hintTextwayPoint0 = 'Search for waypoint'.tr;
|
||||
void clearPlaces(int index) {
|
||||
placeListResponseAll[index] = [];
|
||||
hintTextwayPointStringAll[index] = 'Search for waypoint'.tr;
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -853,7 +874,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
void changeWayPointSheet() {
|
||||
isWayPointSheet = !isWayPointSheet;
|
||||
wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .7;
|
||||
wayPointSheetHeight = isWayPointSheet == false ? 0 : Get.height * .4;
|
||||
// if (heightMenuBool == true) {
|
||||
// getDrawerMenu();
|
||||
// }
|
||||
@@ -878,8 +899,8 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
changeHeightPlaces0() {
|
||||
if (wayPoint0.isEmpty) {
|
||||
changeHeightPlacesAll(int index) {
|
||||
if (placeListResponseAll[index].isEmpty) {
|
||||
height = 0;
|
||||
update();
|
||||
}
|
||||
@@ -953,13 +974,14 @@ class MapPassengerController extends GetxController {
|
||||
update();
|
||||
}
|
||||
|
||||
Future getPlacesListsWayPoint0() async {
|
||||
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()}';
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
|
||||
wayPoint0 = response['results'];
|
||||
placeListResponseAll[index] = response['results'];
|
||||
print(wayPoint0);
|
||||
update();
|
||||
}
|
||||
@@ -1279,13 +1301,6 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
late LatLngBounds boundsData;
|
||||
getMap(String origin, destination) async {
|
||||
var origin1 = fromString(origin);
|
||||
var destination1 = fromString(destination);
|
||||
isLoading = true;
|
||||
update();
|
||||
myDestination = destination1;
|
||||
myLocation = origin1;
|
||||
|
||||
await getCarsLocationByPassenger();
|
||||
// print(carsLocationByPassenger);
|
||||
isLoading = false;
|
||||
@@ -1295,7 +1310,7 @@ class MapPassengerController extends GetxController {
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
print(data);
|
||||
// print(data);
|
||||
isLoading = false;
|
||||
update();
|
||||
durationToRide = data[0]['duration']['value'];
|
||||
@@ -1352,6 +1367,72 @@ class MapPassengerController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
getMapPoints(String origin, destination, int index) async {
|
||||
await getCarsLocationByPassenger();
|
||||
isLoading = false;
|
||||
update();
|
||||
var url =
|
||||
('${AppLink.googleMapsLink}directions/json?&language=en&avoid=tolls|ferries&destination=$destination&origin=$origin&key=${AK.mapAPIKEY}');
|
||||
|
||||
var response = await CRUD().getGoogleApi(link: url, payload: {});
|
||||
data = response['routes'][0]['legs'];
|
||||
// print(data);
|
||||
isLoading = false;
|
||||
update();
|
||||
durationToRide = data[0]['duration']['value'];
|
||||
final points =
|
||||
decodePolyline(response["routes"][0]["overview_polyline"]["points"]);
|
||||
for (int i = 0; i < points.length; i++) {
|
||||
double lat = points[i][0].toDouble();
|
||||
double lng = points[i][1].toDouble();
|
||||
polylineCoordinatesPointsAll[index].add(LatLng(lat, lng));
|
||||
}
|
||||
// Define the northeast and southwest coordinates
|
||||
final bounds = response["routes"][0]["bounds"];
|
||||
|
||||
LatLng northeast =
|
||||
LatLng(bounds['northeast']['lat'], bounds['northeast']['lng']);
|
||||
LatLng southwest =
|
||||
LatLng(bounds['southwest']['lat'], bounds['southwest']['lng']);
|
||||
|
||||
// Create the LatLngBounds object
|
||||
boundsData = LatLngBounds(northeast: northeast, southwest: southwest);
|
||||
|
||||
// Calculate the zoom level based on the distance and screen size
|
||||
|
||||
double distanceOfDestnation =
|
||||
getDistanceFromText(data[0]['distance']['text']);
|
||||
|
||||
// Animate the camera to the adjusted bounds
|
||||
if (distanceOfDestnation <= 5) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
|
||||
} else if (distanceOfDestnation > 5 && distanceOfDestnation <= 8) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 13));
|
||||
} else if (distanceOfDestnation > 8 && distanceOfDestnation < 16) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 12));
|
||||
} else if (distanceOfDestnation >= 16 && distanceOfDestnation < 30) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 11));
|
||||
} else if (distanceOfDestnation >= 30 && distanceOfDestnation < 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 10));
|
||||
} else if (distanceOfDestnation >= 100) {
|
||||
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 7));
|
||||
}
|
||||
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;
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
showBottomSheet1() async {
|
||||
bottomSheet();
|
||||
isBottomSheetShown = true;
|
||||
@@ -1490,12 +1571,26 @@ class MapPassengerController extends GetxController {
|
||||
await CRUD().post(link: AppLink.addTokens, payload: {
|
||||
'token': box.read(BoxName.tokenFCM),
|
||||
'passengerID': box.read(BoxName.passengerID).toString()
|
||||
}).then((value) => print('cccc'));
|
||||
});
|
||||
}
|
||||
|
||||
List<LatLng> polylineCoordinate = [];
|
||||
String? cardNumber;
|
||||
void readyWayPoints() {
|
||||
hintTextwayPointStringAll = [
|
||||
hintTextwayPoint0,
|
||||
hintTextwayPoint1,
|
||||
hintTextwayPoint2,
|
||||
hintTextwayPoint3,
|
||||
hintTextwayPoint4,
|
||||
];
|
||||
polylineCoordinatesPointsAll = [
|
||||
polylineCoordinates0,
|
||||
polylineCoordinates1,
|
||||
polylineCoordinates2,
|
||||
polylineCoordinates3,
|
||||
polylineCoordinates4,
|
||||
];
|
||||
allTextEditingPlaces = [
|
||||
wayPoint0Controller,
|
||||
wayPoint1Controller,
|
||||
@@ -1503,6 +1598,13 @@ class MapPassengerController extends GetxController {
|
||||
wayPoint3Controller,
|
||||
wayPoint4Controller,
|
||||
];
|
||||
currentLocationToFormPlacesAll = [
|
||||
currentLocationToFormPlaces0,
|
||||
currentLocationToFormPlaces1,
|
||||
currentLocationToFormPlaces2,
|
||||
currentLocationToFormPlaces3,
|
||||
currentLocationToFormPlaces4,
|
||||
];
|
||||
placeListResponseAll = [
|
||||
wayPoint0,
|
||||
wayPoint1,
|
||||
@@ -1510,22 +1612,34 @@ class MapPassengerController extends GetxController {
|
||||
wayPoint3,
|
||||
wayPoint4
|
||||
];
|
||||
startLocationFromMapAll = [
|
||||
startLocationFromMap0,
|
||||
startLocationFromMap1,
|
||||
startLocationFromMap2,
|
||||
startLocationFromMap3,
|
||||
startLocationFromMap4,
|
||||
];
|
||||
currentLocationStringAll = [
|
||||
currentLocationString0,
|
||||
currentLocationString1,
|
||||
currentLocationString2,
|
||||
currentLocationString3,
|
||||
currentLocationString4,
|
||||
]; // placeListResponse.add(wayPoint0);
|
||||
// placeListResponse.add(wayPoint1);
|
||||
// placeListResponse.add(wayPoint2);
|
||||
// placeListResponse.add(wayPoint3);
|
||||
// placeListResponse.add(wayPoint4);
|
||||
];
|
||||
placesCoordinate = [
|
||||
placesCoordinate0,
|
||||
placesCoordinate1,
|
||||
placesCoordinate2,
|
||||
placesCoordinate3,
|
||||
placesCoordinate4,
|
||||
];
|
||||
update();
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
mapAPIKEY = await storage.read(key: BoxName.mapAPIKEY);
|
||||
readyWayPoints();
|
||||
await getLocation();
|
||||
await addToken();
|
||||
await getCarsLocationByPassenger();
|
||||
@@ -1535,7 +1649,6 @@ class MapPassengerController extends GetxController {
|
||||
addCustomTripIcon();
|
||||
startMarkerReloading();
|
||||
cardNumber = await SecureStorage().readData(BoxName.cardNumber);
|
||||
readyWayPoints();
|
||||
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ class WayPointController extends GetxController {
|
||||
TextEditingController textSearchCotroller = TextEditingController();
|
||||
// A list of places corresponding to each text field
|
||||
final places = <String>[];
|
||||
|
||||
final hintTextPointList = <String>[];
|
||||
late LatLng myLocation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user