Update: 2026-06-26 04:53:05
This commit is contained in:
@@ -1601,7 +1601,7 @@ class RideLifecycleController extends GetxController {
|
||||
.where((p) =>
|
||||
!p.polylineId.value.startsWith('driver_route') &&
|
||||
p.polylineId.value != 'main_route' &&
|
||||
p.polylineId.value != 'route_primary' &&
|
||||
!p.polylineId.value.startsWith('route_primary') &&
|
||||
p.polylineId.value != 'route_direct')
|
||||
.toSet();
|
||||
|
||||
@@ -2085,7 +2085,7 @@ class RideLifecycleController extends GetxController {
|
||||
.where((p) =>
|
||||
!p.polylineId.value.startsWith('driver_route') &&
|
||||
p.polylineId.value != 'main_route' &&
|
||||
p.polylineId.value != 'route_primary' &&
|
||||
!p.polylineId.value.startsWith('route_primary') &&
|
||||
p.polylineId.value != 'route_direct')
|
||||
.toSet();
|
||||
|
||||
@@ -2109,7 +2109,7 @@ class RideLifecycleController extends GetxController {
|
||||
.where((p) =>
|
||||
!p.polylineId.value.startsWith('driver_route') &&
|
||||
p.polylineId.value != 'main_route' &&
|
||||
p.polylineId.value != 'route_primary' &&
|
||||
!p.polylineId.value.startsWith('route_primary') &&
|
||||
p.polylineId.value != 'route_direct')
|
||||
.toSet();
|
||||
// حالة Apply/Arrived: خط متصل صلب بدل المتقطع
|
||||
@@ -2231,7 +2231,7 @@ class RideLifecycleController extends GetxController {
|
||||
polyLines = polyLines
|
||||
.where((p) =>
|
||||
!p.polylineId.value.startsWith('driver_route') &&
|
||||
p.polylineId.value != 'route_primary' &&
|
||||
!p.polylineId.value.startsWith('route_primary') &&
|
||||
p.polylineId.value != 'route_direct')
|
||||
.toSet();
|
||||
|
||||
@@ -2348,14 +2348,14 @@ class RideLifecycleController extends GetxController {
|
||||
double newHeading =
|
||||
double.tryParse(driverData['heading'].toString()) ?? 0.0;
|
||||
|
||||
String icon;
|
||||
String iconPath;
|
||||
if (driverData['model'].toString().contains('دراجة') ||
|
||||
driverData['make'].toString().contains('دراجة')) {
|
||||
icon = mapEngine.motoIcon;
|
||||
iconPath = 'assets/images/moto.png';
|
||||
} else if (driverData['gender'] == 'Female') {
|
||||
icon = mapEngine.ladyIcon;
|
||||
iconPath = 'assets/images/lady.png';
|
||||
} else {
|
||||
icon = mapEngine.carIcon;
|
||||
iconPath = 'assets/images/car.png';
|
||||
}
|
||||
|
||||
final String markerId = 'assigned_driver_marker';
|
||||
@@ -2367,7 +2367,7 @@ class RideLifecycleController extends GetxController {
|
||||
|
||||
if (existingMarker != null) {
|
||||
mapEngine.smoothlyUpdateMarker(
|
||||
existingMarker, newPosition, newHeading, icon);
|
||||
existingMarker, newPosition, newHeading, iconPath);
|
||||
} else {
|
||||
markers = {
|
||||
...markers,
|
||||
@@ -2375,7 +2375,7 @@ class RideLifecycleController extends GetxController {
|
||||
markerId: mId,
|
||||
position: newPosition,
|
||||
rotation: newHeading,
|
||||
icon: InlqBitmap.fromStyleImage(icon),
|
||||
icon: InlqBitmap.fromAsset(iconPath),
|
||||
anchor: const Offset(0.5, 0.5),
|
||||
),
|
||||
};
|
||||
@@ -2383,19 +2383,21 @@ class RideLifecycleController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
String _driverIconAssetPath() {
|
||||
if (model.contains('دراجة') || make.contains('دراجة')) {
|
||||
return 'assets/images/moto.png';
|
||||
} else if (gender == 'Female') {
|
||||
return 'assets/images/lady.png';
|
||||
} else {
|
||||
return 'assets/images/car.png';
|
||||
}
|
||||
}
|
||||
|
||||
void updateDriverMarker(LatLng position, double heading) {
|
||||
const String markerId = 'assigned_driver_marker';
|
||||
const mId = MarkerId(markerId);
|
||||
|
||||
// Choose icon based on vehicle type
|
||||
String icon;
|
||||
if (model.contains('دراجة') || make.contains('دراجة')) {
|
||||
icon = mapEngine.motoIcon;
|
||||
} else if (gender == 'Female') {
|
||||
icon = mapEngine.ladyIcon;
|
||||
} else {
|
||||
icon = mapEngine.carIcon;
|
||||
}
|
||||
final String iconPath = _driverIconAssetPath();
|
||||
|
||||
final existingMarker = markers.cast<Marker?>().firstWhere(
|
||||
(m) => m?.markerId == mId,
|
||||
@@ -2403,14 +2405,15 @@ class RideLifecycleController extends GetxController {
|
||||
);
|
||||
|
||||
if (existingMarker != null) {
|
||||
mapEngine.smoothlyUpdateMarker(existingMarker, position, heading, icon);
|
||||
mapEngine.smoothlyUpdateMarker(
|
||||
existingMarker, position, heading, iconPath);
|
||||
} else {
|
||||
markers = {
|
||||
...markers,
|
||||
Marker(
|
||||
markerId: mId,
|
||||
position: position,
|
||||
icon: InlqBitmap.fromStyleImage(icon),
|
||||
icon: InlqBitmap.fromAsset(iconPath),
|
||||
rotation: heading,
|
||||
anchor: const Offset(0.5, 0.5),
|
||||
),
|
||||
@@ -3490,7 +3493,10 @@ class RideLifecycleController extends GetxController {
|
||||
hours = durationToAdd.inHours;
|
||||
minutes = (durationToAdd.inMinutes % 60).round();
|
||||
|
||||
if (polyLines.isNotEmpty) mapEngine.clearPolyline();
|
||||
if (polyLines.isNotEmpty) {
|
||||
mapEngine.clearPolyline();
|
||||
await Future<void>.delayed(Duration.zero);
|
||||
}
|
||||
|
||||
rideConfirm = false;
|
||||
isMarkersShown = true;
|
||||
@@ -3501,28 +3507,19 @@ class RideLifecycleController extends GetxController {
|
||||
await mapEngine.playRouteAnimation(
|
||||
mapEngine.polylineCoordinates, mapEngine.lastComputedBounds);
|
||||
|
||||
// ✅ FIX P1: انتظار تحميل الأيقونات قبل إنشاء الـ markers
|
||||
// intaleq_maps تتطلب صوراً مسجلة عبر addImage() وليس أصولاً مباشرة
|
||||
if (!mapEngine.isIconsLoaded) {
|
||||
Log.print('⏳ Waiting for map icons to load before placing markers...');
|
||||
for (int i = 0; i < 20 && !mapEngine.isIconsLoaded; i++) {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ FIX P1: استخدام fromStyleImage مع المعرّفات المسجلة مسبقاً
|
||||
markers = {
|
||||
// بناء Set كاملة دفعة واحدة ثم تعيينها
|
||||
final Set<Marker> newMarkers = {
|
||||
Marker(
|
||||
markerId: const MarkerId('start'),
|
||||
position: startLoc,
|
||||
icon: InlqBitmap.fromStyleImage(mapEngine.startIcon),
|
||||
icon: InlqBitmap.fromAsset('assets/images/A.png'),
|
||||
infoWindow: const InfoWindow(title: 'A'),
|
||||
anchor: const Offset(0.5, 1.0),
|
||||
),
|
||||
Marker(
|
||||
markerId: const MarkerId('end'),
|
||||
position: endLoc,
|
||||
icon: InlqBitmap.fromStyleImage(mapEngine.endIcon),
|
||||
icon: InlqBitmap.fromAsset('assets/images/b.png'),
|
||||
infoWindow: const InfoWindow(title: 'B'),
|
||||
anchor: const Offset(0.5, 1.0),
|
||||
),
|
||||
@@ -3532,11 +3529,12 @@ class RideLifecycleController extends GetxController {
|
||||
final wp = menuWaypoints[i];
|
||||
if (wp != null) {
|
||||
final bool isFirstWaypoint = i == 0;
|
||||
markers.add(Marker(
|
||||
newMarkers.add(Marker(
|
||||
markerId: MarkerId('waypoint_$i'),
|
||||
position: wp,
|
||||
icon: InlqBitmap.fromStyleImage(
|
||||
isFirstWaypoint ? mapEngine.startIcon : mapEngine.endIcon),
|
||||
icon: InlqBitmap.fromAsset(isFirstWaypoint
|
||||
? 'assets/images/A.png'
|
||||
: 'assets/images/b.png'),
|
||||
infoWindow:
|
||||
InfoWindow(title: isFirstWaypoint ? 'Stop 1' : 'Stop 2'),
|
||||
anchor: const Offset(0.5, 1.0),
|
||||
@@ -3544,8 +3542,11 @@ class RideLifecycleController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Log.print('✅ FIX P1: Markers placed — start: $startLoc, end: $endLoc');
|
||||
update();
|
||||
// تعيين الـ markers مباشرة في mapEngine (بدون setter لتجنب update() مضاعف)
|
||||
mapEngine.markers = newMarkers;
|
||||
Log.print(
|
||||
'✅ FIX P1 v2: ${newMarkers.length} markers placed — start: $startLoc, end: $endLoc');
|
||||
mapEngine.update();
|
||||
} catch (e, stackTrace) {
|
||||
if (isDrawingRoute) {
|
||||
isDrawingRoute = false;
|
||||
@@ -3805,9 +3806,11 @@ class RideLifecycleController extends GetxController {
|
||||
if (response is Map<String, dynamic>) {
|
||||
final data = response['data'];
|
||||
if (data is String) return data;
|
||||
Log.print("⚠️ getRideStatus: data is not a String, got: ${data.runtimeType}");
|
||||
Log.print(
|
||||
"⚠️ getRideStatus: data is not a String, got: ${data.runtimeType}");
|
||||
} else {
|
||||
Log.print("⚠️ getRideStatus: response is not a Map, got: ${response.runtimeType}");
|
||||
Log.print(
|
||||
"⚠️ getRideStatus: response is not a Map, got: ${response.runtimeType}");
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user