Update: 2026-06-26 04:53:05
This commit is contained in:
@@ -44,6 +44,7 @@ class MapEngineController extends GetxController {
|
||||
String carIcon = "car_icon";
|
||||
String motoIcon = "moto_icon";
|
||||
String ladyIcon = "lady_icon";
|
||||
int _routeRenderRevision = 0;
|
||||
|
||||
double height = 150;
|
||||
double heightMenu = 0;
|
||||
@@ -59,6 +60,7 @@ class MapEngineController extends GetxController {
|
||||
_isPickerShown = value;
|
||||
update();
|
||||
}
|
||||
|
||||
bool isPointsPageForRider = false;
|
||||
bool isBottomSheetShown = false;
|
||||
bool reloadStartApp = false;
|
||||
@@ -218,7 +220,7 @@ class MapEngineController extends GetxController {
|
||||
}
|
||||
|
||||
void clearPolyline() {
|
||||
polyLines.clear();
|
||||
polyLines = <Polyline>{};
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -255,6 +257,8 @@ class MapEngineController extends GetxController {
|
||||
|
||||
Future<void> playRouteAnimation(
|
||||
List<LatLng> coords, LatLngBounds? bounds) async {
|
||||
_routeRenderRevision++;
|
||||
|
||||
const List<Color> segmentColors = [
|
||||
Color(0xFF109642), // Green
|
||||
Color(0xFFF59E0B), // Amber
|
||||
@@ -296,7 +300,7 @@ class MapEngineController extends GetxController {
|
||||
final color = segmentColors[s % segmentColors.length];
|
||||
|
||||
newPolylines.add(Polyline(
|
||||
polylineId: PolylineId('segment_$s'),
|
||||
polylineId: PolylineId('route_primary_${_routeRenderRevision}_$s'),
|
||||
points: segCoords,
|
||||
color: color,
|
||||
width: 6,
|
||||
@@ -304,7 +308,7 @@ class MapEngineController extends GetxController {
|
||||
}
|
||||
} else {
|
||||
newPolylines.add(Polyline(
|
||||
polylineId: const PolylineId('route_primary'),
|
||||
polylineId: PolylineId('route_primary_${_routeRenderRevision}_0'),
|
||||
points: coords,
|
||||
color: AppColor.primaryColor,
|
||||
width: 6,
|
||||
@@ -414,7 +418,7 @@ class MapEngineController extends GetxController {
|
||||
markerId: mId,
|
||||
position: newPosition,
|
||||
rotation: newHeading,
|
||||
icon: InlqBitmap.fromStyleImage(icon),
|
||||
icon: InlqBitmap.fromAsset(icon),
|
||||
anchor: const Offset(0.5, 0.5),
|
||||
),
|
||||
};
|
||||
@@ -465,7 +469,7 @@ class MapEngineController extends GetxController {
|
||||
final updatedMarker = oldMarker.copyWith(
|
||||
position: currentPos,
|
||||
rotation: currentHeading,
|
||||
icon: InlqBitmap.fromStyleImage(icon),
|
||||
icon: InlqBitmap.fromAsset(icon),
|
||||
);
|
||||
|
||||
markers = {
|
||||
@@ -715,6 +719,8 @@ class MapEngineController extends GetxController {
|
||||
|
||||
Future<void> _playRouteAnimation(
|
||||
List<LatLng> coords, LatLngBounds? bounds) async {
|
||||
_routeRenderRevision++;
|
||||
|
||||
const List<Color> segmentColors = [
|
||||
Color(0xFF109642), // Green
|
||||
Color(0xFFF59E0B), // Amber
|
||||
@@ -756,7 +762,7 @@ class MapEngineController extends GetxController {
|
||||
final color = segmentColors[s % segmentColors.length];
|
||||
|
||||
newPolylines.add(Polyline(
|
||||
polylineId: PolylineId('segment_$s'),
|
||||
polylineId: PolylineId('route_primary_${_routeRenderRevision}_$s'),
|
||||
points: segCoords,
|
||||
color: color,
|
||||
width: 6,
|
||||
@@ -764,7 +770,7 @@ class MapEngineController extends GetxController {
|
||||
}
|
||||
} else {
|
||||
newPolylines.add(Polyline(
|
||||
polylineId: const PolylineId('route_primary'),
|
||||
polylineId: PolylineId('route_primary_${_routeRenderRevision}_0'),
|
||||
points: coords,
|
||||
color: AppColor.primaryColor,
|
||||
width: 6,
|
||||
@@ -803,8 +809,8 @@ class MapEngineController extends GetxController {
|
||||
mainBottomMenuMapHeight = Get.height * 0.22;
|
||||
wayPointSheetHeight = 0;
|
||||
|
||||
markers.clear();
|
||||
polyLines.clear();
|
||||
markers = <Marker>{};
|
||||
polyLines = <Polyline>{};
|
||||
polylineCoordinates.clear();
|
||||
|
||||
_animationTimers.forEach((key, timer) => timer.cancel());
|
||||
|
||||
@@ -322,13 +322,12 @@ class NearbyDriversController extends GetxController {
|
||||
}
|
||||
|
||||
String _getIconForCar(Map<String, dynamic> carData) {
|
||||
final mapEngine = Get.find<MapEngineController>();
|
||||
if (carData['model'].toString().contains('دراجة')) {
|
||||
return mapEngine.motoIcon;
|
||||
return 'assets/images/moto.png';
|
||||
} else if (carData['gender'] == 'Female') {
|
||||
return mapEngine.ladyIcon;
|
||||
return 'assets/images/lady.png';
|
||||
} else {
|
||||
return mapEngine.carIcon;
|
||||
return 'assets/images/car.png';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +351,7 @@ class NearbyDriversController extends GetxController {
|
||||
markerId: mId,
|
||||
position: newPosition,
|
||||
rotation: newHeading,
|
||||
icon: InlqBitmap.fromStyleImage(icon),
|
||||
icon: InlqBitmap.fromAsset(icon),
|
||||
anchor: const Offset(0.5, 0.5),
|
||||
),
|
||||
};
|
||||
@@ -400,7 +399,7 @@ class NearbyDriversController extends GetxController {
|
||||
final updatedMarker = oldMarker.copyWith(
|
||||
position: currentPos,
|
||||
rotation: currentHeading,
|
||||
icon: InlqBitmap.fromStyleImage(icon),
|
||||
icon: InlqBitmap.fromAsset(icon),
|
||||
);
|
||||
|
||||
mapEngine.markers = {
|
||||
|
||||
@@ -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