This commit is contained in:
Hamza-Ayed
2024-01-24 01:58:52 +03:00
parent 8aaca3630d
commit 1eab187076
13 changed files with 299 additions and 189 deletions

View File

@@ -26,6 +26,9 @@ class MapDriverController extends GetxController {
List dataDestination = [];
LatLngBounds? boundsData;
BitmapDescriptor carIcon = BitmapDescriptor.defaultMarker;
BitmapDescriptor passengerIcon = BitmapDescriptor.defaultMarker;
BitmapDescriptor startIcon = BitmapDescriptor.defaultMarker;
BitmapDescriptor endIcon = BitmapDescriptor.defaultMarker;
final List<LatLng> polylineCoordinates = [];
final List<LatLng> polylineCoordinatesDestination = [];
List<Polyline> polyLines = [];
@@ -75,6 +78,8 @@ class MapDriverController extends GetxController {
String? mapAPIKEY;
final zones = <Zone>[];
String canelString = 'yet';
late LatLng latLngpassengerLocation;
late LatLng latLngPassengerDestination;
void onMapCreated(GoogleMapController controller) async {
myLocation = Get.find<LocationController>().location as LatLng;
@@ -229,6 +234,8 @@ class MapDriverController extends GetxController {
'driverID': box.read(BoxName.driverID).toString(),
});
var d = jsonDecode(res);
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 18));
update();
print('...................');
print(d);
print('...................');
@@ -337,17 +344,55 @@ class MapDriverController extends GetxController {
}
void addCustomCarIcon() {
ImageConfiguration config = const ImageConfiguration(
size: Size(20, 20),
// scale: 1.0,
);
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png')
ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio
// scale: 1.0,
);
BitmapDescriptor.fromAssetImage(config, 'assets/images/car.png',
mipmaps: false)
.then((value) {
carIcon = value;
update();
});
}
void addCustomStartIcon() async {
// Create the marker with the resized image
ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
BitmapDescriptor.fromAssetImage(config, 'assets/images/A.png',
mipmaps: false)
.then((value) {
startIcon = value;
update();
});
}
void addCustomEndIcon() {
ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio);
BitmapDescriptor.fromAssetImage(config, 'assets/images/b.png',
mipmaps: false)
.then((value) {
endIcon = value;
update();
});
}
void addCustomPassengerIcon() {
ImageConfiguration config = ImageConfiguration(
size: const Size(30, 30), devicePixelRatio: Get.pixelRatio
// scale: 1.0,
);
BitmapDescriptor.fromAssetImage(config, 'assets/images/picker.png',
mipmaps: false)
.then((value) {
passengerIcon = value;
update();
});
}
getMap(String origin, destination) async {
isLoading = false;
@@ -384,7 +429,7 @@ class MapDriverController extends GetxController {
width: 10,
color: AppColor.blueColor,
);
mapController!.animateCamera(CameraUpdate.newLatLngZoom(myLocation, 14));
polyLines.add(polyline);
// rideConfirm = false;
update();
@@ -406,7 +451,7 @@ class MapDriverController extends GetxController {
polylineCoordinatesDestination.add(LatLng(lat, lng));
}
if (polyLinesDestination.isNotEmpty) {
clearPolyline();
// clearPolyline();
var polyline = Polyline(
polylineId: PolylineId(response["routes"][0]["summary"]),
points: polylineCoordinatesDestination,
@@ -462,6 +507,19 @@ class MapDriverController extends GetxController {
step2 = Get.arguments['step2'];
step3 = Get.arguments['step3'];
step4 = Get.arguments['step4'];
var coords = passengerLocation.split(',');
var coordDestination = passengerDestination.split(',');
// Parse to double
double latPassengerLocation = double.parse(coords[0]);
double lngPassengerLocation = double.parse(coords[1]);
double latPassengerDestination = double.parse(coordDestination[0]);
double lngPassengerDestination = double.parse(coordDestination[1]);
latLngpassengerLocation =
LatLng(latPassengerLocation, lngPassengerLocation);
latLngPassengerDestination =
LatLng(latPassengerDestination, lngPassengerDestination);
String lat = Get.find<LocationController>().myLocation.latitude.toString();
String lng = Get.find<LocationController>().myLocation.longitude.toString();
String origin = '$lat,$lng';
@@ -476,6 +534,9 @@ class MapDriverController extends GetxController {
)
: await getMapDestination(passengerLocation, passengerDestination);
addCustomCarIcon();
addCustomPassengerIcon();
addCustomStartIcon();
addCustomEndIcon();
// updateMarker();
startTimerToShowPassengerInfoWindowFromDriver();
// cancelCheckRidefromPassenger();