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 carIcon = "car_icon";
|
||||||
String motoIcon = "moto_icon";
|
String motoIcon = "moto_icon";
|
||||||
String ladyIcon = "lady_icon";
|
String ladyIcon = "lady_icon";
|
||||||
|
int _routeRenderRevision = 0;
|
||||||
|
|
||||||
double height = 150;
|
double height = 150;
|
||||||
double heightMenu = 0;
|
double heightMenu = 0;
|
||||||
@@ -59,6 +60,7 @@ class MapEngineController extends GetxController {
|
|||||||
_isPickerShown = value;
|
_isPickerShown = value;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isPointsPageForRider = false;
|
bool isPointsPageForRider = false;
|
||||||
bool isBottomSheetShown = false;
|
bool isBottomSheetShown = false;
|
||||||
bool reloadStartApp = false;
|
bool reloadStartApp = false;
|
||||||
@@ -218,7 +220,7 @@ class MapEngineController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clearPolyline() {
|
void clearPolyline() {
|
||||||
polyLines.clear();
|
polyLines = <Polyline>{};
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +257,8 @@ class MapEngineController extends GetxController {
|
|||||||
|
|
||||||
Future<void> playRouteAnimation(
|
Future<void> playRouteAnimation(
|
||||||
List<LatLng> coords, LatLngBounds? bounds) async {
|
List<LatLng> coords, LatLngBounds? bounds) async {
|
||||||
|
_routeRenderRevision++;
|
||||||
|
|
||||||
const List<Color> segmentColors = [
|
const List<Color> segmentColors = [
|
||||||
Color(0xFF109642), // Green
|
Color(0xFF109642), // Green
|
||||||
Color(0xFFF59E0B), // Amber
|
Color(0xFFF59E0B), // Amber
|
||||||
@@ -296,7 +300,7 @@ class MapEngineController extends GetxController {
|
|||||||
final color = segmentColors[s % segmentColors.length];
|
final color = segmentColors[s % segmentColors.length];
|
||||||
|
|
||||||
newPolylines.add(Polyline(
|
newPolylines.add(Polyline(
|
||||||
polylineId: PolylineId('segment_$s'),
|
polylineId: PolylineId('route_primary_${_routeRenderRevision}_$s'),
|
||||||
points: segCoords,
|
points: segCoords,
|
||||||
color: color,
|
color: color,
|
||||||
width: 6,
|
width: 6,
|
||||||
@@ -304,7 +308,7 @@ class MapEngineController extends GetxController {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newPolylines.add(Polyline(
|
newPolylines.add(Polyline(
|
||||||
polylineId: const PolylineId('route_primary'),
|
polylineId: PolylineId('route_primary_${_routeRenderRevision}_0'),
|
||||||
points: coords,
|
points: coords,
|
||||||
color: AppColor.primaryColor,
|
color: AppColor.primaryColor,
|
||||||
width: 6,
|
width: 6,
|
||||||
@@ -414,7 +418,7 @@ class MapEngineController extends GetxController {
|
|||||||
markerId: mId,
|
markerId: mId,
|
||||||
position: newPosition,
|
position: newPosition,
|
||||||
rotation: newHeading,
|
rotation: newHeading,
|
||||||
icon: InlqBitmap.fromStyleImage(icon),
|
icon: InlqBitmap.fromAsset(icon),
|
||||||
anchor: const Offset(0.5, 0.5),
|
anchor: const Offset(0.5, 0.5),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -465,7 +469,7 @@ class MapEngineController extends GetxController {
|
|||||||
final updatedMarker = oldMarker.copyWith(
|
final updatedMarker = oldMarker.copyWith(
|
||||||
position: currentPos,
|
position: currentPos,
|
||||||
rotation: currentHeading,
|
rotation: currentHeading,
|
||||||
icon: InlqBitmap.fromStyleImage(icon),
|
icon: InlqBitmap.fromAsset(icon),
|
||||||
);
|
);
|
||||||
|
|
||||||
markers = {
|
markers = {
|
||||||
@@ -715,6 +719,8 @@ class MapEngineController extends GetxController {
|
|||||||
|
|
||||||
Future<void> _playRouteAnimation(
|
Future<void> _playRouteAnimation(
|
||||||
List<LatLng> coords, LatLngBounds? bounds) async {
|
List<LatLng> coords, LatLngBounds? bounds) async {
|
||||||
|
_routeRenderRevision++;
|
||||||
|
|
||||||
const List<Color> segmentColors = [
|
const List<Color> segmentColors = [
|
||||||
Color(0xFF109642), // Green
|
Color(0xFF109642), // Green
|
||||||
Color(0xFFF59E0B), // Amber
|
Color(0xFFF59E0B), // Amber
|
||||||
@@ -756,7 +762,7 @@ class MapEngineController extends GetxController {
|
|||||||
final color = segmentColors[s % segmentColors.length];
|
final color = segmentColors[s % segmentColors.length];
|
||||||
|
|
||||||
newPolylines.add(Polyline(
|
newPolylines.add(Polyline(
|
||||||
polylineId: PolylineId('segment_$s'),
|
polylineId: PolylineId('route_primary_${_routeRenderRevision}_$s'),
|
||||||
points: segCoords,
|
points: segCoords,
|
||||||
color: color,
|
color: color,
|
||||||
width: 6,
|
width: 6,
|
||||||
@@ -764,7 +770,7 @@ class MapEngineController extends GetxController {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newPolylines.add(Polyline(
|
newPolylines.add(Polyline(
|
||||||
polylineId: const PolylineId('route_primary'),
|
polylineId: PolylineId('route_primary_${_routeRenderRevision}_0'),
|
||||||
points: coords,
|
points: coords,
|
||||||
color: AppColor.primaryColor,
|
color: AppColor.primaryColor,
|
||||||
width: 6,
|
width: 6,
|
||||||
@@ -803,8 +809,8 @@ class MapEngineController extends GetxController {
|
|||||||
mainBottomMenuMapHeight = Get.height * 0.22;
|
mainBottomMenuMapHeight = Get.height * 0.22;
|
||||||
wayPointSheetHeight = 0;
|
wayPointSheetHeight = 0;
|
||||||
|
|
||||||
markers.clear();
|
markers = <Marker>{};
|
||||||
polyLines.clear();
|
polyLines = <Polyline>{};
|
||||||
polylineCoordinates.clear();
|
polylineCoordinates.clear();
|
||||||
|
|
||||||
_animationTimers.forEach((key, timer) => timer.cancel());
|
_animationTimers.forEach((key, timer) => timer.cancel());
|
||||||
|
|||||||
@@ -322,13 +322,12 @@ class NearbyDriversController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String _getIconForCar(Map<String, dynamic> carData) {
|
String _getIconForCar(Map<String, dynamic> carData) {
|
||||||
final mapEngine = Get.find<MapEngineController>();
|
|
||||||
if (carData['model'].toString().contains('دراجة')) {
|
if (carData['model'].toString().contains('دراجة')) {
|
||||||
return mapEngine.motoIcon;
|
return 'assets/images/moto.png';
|
||||||
} else if (carData['gender'] == 'Female') {
|
} else if (carData['gender'] == 'Female') {
|
||||||
return mapEngine.ladyIcon;
|
return 'assets/images/lady.png';
|
||||||
} else {
|
} else {
|
||||||
return mapEngine.carIcon;
|
return 'assets/images/car.png';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +351,7 @@ class NearbyDriversController extends GetxController {
|
|||||||
markerId: mId,
|
markerId: mId,
|
||||||
position: newPosition,
|
position: newPosition,
|
||||||
rotation: newHeading,
|
rotation: newHeading,
|
||||||
icon: InlqBitmap.fromStyleImage(icon),
|
icon: InlqBitmap.fromAsset(icon),
|
||||||
anchor: const Offset(0.5, 0.5),
|
anchor: const Offset(0.5, 0.5),
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
@@ -400,7 +399,7 @@ class NearbyDriversController extends GetxController {
|
|||||||
final updatedMarker = oldMarker.copyWith(
|
final updatedMarker = oldMarker.copyWith(
|
||||||
position: currentPos,
|
position: currentPos,
|
||||||
rotation: currentHeading,
|
rotation: currentHeading,
|
||||||
icon: InlqBitmap.fromStyleImage(icon),
|
icon: InlqBitmap.fromAsset(icon),
|
||||||
);
|
);
|
||||||
|
|
||||||
mapEngine.markers = {
|
mapEngine.markers = {
|
||||||
|
|||||||
@@ -1601,7 +1601,7 @@ class RideLifecycleController extends GetxController {
|
|||||||
.where((p) =>
|
.where((p) =>
|
||||||
!p.polylineId.value.startsWith('driver_route') &&
|
!p.polylineId.value.startsWith('driver_route') &&
|
||||||
p.polylineId.value != 'main_route' &&
|
p.polylineId.value != 'main_route' &&
|
||||||
p.polylineId.value != 'route_primary' &&
|
!p.polylineId.value.startsWith('route_primary') &&
|
||||||
p.polylineId.value != 'route_direct')
|
p.polylineId.value != 'route_direct')
|
||||||
.toSet();
|
.toSet();
|
||||||
|
|
||||||
@@ -2085,7 +2085,7 @@ class RideLifecycleController extends GetxController {
|
|||||||
.where((p) =>
|
.where((p) =>
|
||||||
!p.polylineId.value.startsWith('driver_route') &&
|
!p.polylineId.value.startsWith('driver_route') &&
|
||||||
p.polylineId.value != 'main_route' &&
|
p.polylineId.value != 'main_route' &&
|
||||||
p.polylineId.value != 'route_primary' &&
|
!p.polylineId.value.startsWith('route_primary') &&
|
||||||
p.polylineId.value != 'route_direct')
|
p.polylineId.value != 'route_direct')
|
||||||
.toSet();
|
.toSet();
|
||||||
|
|
||||||
@@ -2109,7 +2109,7 @@ class RideLifecycleController extends GetxController {
|
|||||||
.where((p) =>
|
.where((p) =>
|
||||||
!p.polylineId.value.startsWith('driver_route') &&
|
!p.polylineId.value.startsWith('driver_route') &&
|
||||||
p.polylineId.value != 'main_route' &&
|
p.polylineId.value != 'main_route' &&
|
||||||
p.polylineId.value != 'route_primary' &&
|
!p.polylineId.value.startsWith('route_primary') &&
|
||||||
p.polylineId.value != 'route_direct')
|
p.polylineId.value != 'route_direct')
|
||||||
.toSet();
|
.toSet();
|
||||||
// حالة Apply/Arrived: خط متصل صلب بدل المتقطع
|
// حالة Apply/Arrived: خط متصل صلب بدل المتقطع
|
||||||
@@ -2231,7 +2231,7 @@ class RideLifecycleController extends GetxController {
|
|||||||
polyLines = polyLines
|
polyLines = polyLines
|
||||||
.where((p) =>
|
.where((p) =>
|
||||||
!p.polylineId.value.startsWith('driver_route') &&
|
!p.polylineId.value.startsWith('driver_route') &&
|
||||||
p.polylineId.value != 'route_primary' &&
|
!p.polylineId.value.startsWith('route_primary') &&
|
||||||
p.polylineId.value != 'route_direct')
|
p.polylineId.value != 'route_direct')
|
||||||
.toSet();
|
.toSet();
|
||||||
|
|
||||||
@@ -2348,14 +2348,14 @@ class RideLifecycleController extends GetxController {
|
|||||||
double newHeading =
|
double newHeading =
|
||||||
double.tryParse(driverData['heading'].toString()) ?? 0.0;
|
double.tryParse(driverData['heading'].toString()) ?? 0.0;
|
||||||
|
|
||||||
String icon;
|
String iconPath;
|
||||||
if (driverData['model'].toString().contains('دراجة') ||
|
if (driverData['model'].toString().contains('دراجة') ||
|
||||||
driverData['make'].toString().contains('دراجة')) {
|
driverData['make'].toString().contains('دراجة')) {
|
||||||
icon = mapEngine.motoIcon;
|
iconPath = 'assets/images/moto.png';
|
||||||
} else if (driverData['gender'] == 'Female') {
|
} else if (driverData['gender'] == 'Female') {
|
||||||
icon = mapEngine.ladyIcon;
|
iconPath = 'assets/images/lady.png';
|
||||||
} else {
|
} else {
|
||||||
icon = mapEngine.carIcon;
|
iconPath = 'assets/images/car.png';
|
||||||
}
|
}
|
||||||
|
|
||||||
final String markerId = 'assigned_driver_marker';
|
final String markerId = 'assigned_driver_marker';
|
||||||
@@ -2367,7 +2367,7 @@ class RideLifecycleController extends GetxController {
|
|||||||
|
|
||||||
if (existingMarker != null) {
|
if (existingMarker != null) {
|
||||||
mapEngine.smoothlyUpdateMarker(
|
mapEngine.smoothlyUpdateMarker(
|
||||||
existingMarker, newPosition, newHeading, icon);
|
existingMarker, newPosition, newHeading, iconPath);
|
||||||
} else {
|
} else {
|
||||||
markers = {
|
markers = {
|
||||||
...markers,
|
...markers,
|
||||||
@@ -2375,7 +2375,7 @@ class RideLifecycleController extends GetxController {
|
|||||||
markerId: mId,
|
markerId: mId,
|
||||||
position: newPosition,
|
position: newPosition,
|
||||||
rotation: newHeading,
|
rotation: newHeading,
|
||||||
icon: InlqBitmap.fromStyleImage(icon),
|
icon: InlqBitmap.fromAsset(iconPath),
|
||||||
anchor: const Offset(0.5, 0.5),
|
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) {
|
void updateDriverMarker(LatLng position, double heading) {
|
||||||
const String markerId = 'assigned_driver_marker';
|
const String markerId = 'assigned_driver_marker';
|
||||||
const mId = MarkerId(markerId);
|
const mId = MarkerId(markerId);
|
||||||
|
|
||||||
// Choose icon based on vehicle type
|
final String iconPath = _driverIconAssetPath();
|
||||||
String icon;
|
|
||||||
if (model.contains('دراجة') || make.contains('دراجة')) {
|
|
||||||
icon = mapEngine.motoIcon;
|
|
||||||
} else if (gender == 'Female') {
|
|
||||||
icon = mapEngine.ladyIcon;
|
|
||||||
} else {
|
|
||||||
icon = mapEngine.carIcon;
|
|
||||||
}
|
|
||||||
|
|
||||||
final existingMarker = markers.cast<Marker?>().firstWhere(
|
final existingMarker = markers.cast<Marker?>().firstWhere(
|
||||||
(m) => m?.markerId == mId,
|
(m) => m?.markerId == mId,
|
||||||
@@ -2403,14 +2405,15 @@ class RideLifecycleController extends GetxController {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (existingMarker != null) {
|
if (existingMarker != null) {
|
||||||
mapEngine.smoothlyUpdateMarker(existingMarker, position, heading, icon);
|
mapEngine.smoothlyUpdateMarker(
|
||||||
|
existingMarker, position, heading, iconPath);
|
||||||
} else {
|
} else {
|
||||||
markers = {
|
markers = {
|
||||||
...markers,
|
...markers,
|
||||||
Marker(
|
Marker(
|
||||||
markerId: mId,
|
markerId: mId,
|
||||||
position: position,
|
position: position,
|
||||||
icon: InlqBitmap.fromStyleImage(icon),
|
icon: InlqBitmap.fromAsset(iconPath),
|
||||||
rotation: heading,
|
rotation: heading,
|
||||||
anchor: const Offset(0.5, 0.5),
|
anchor: const Offset(0.5, 0.5),
|
||||||
),
|
),
|
||||||
@@ -3490,7 +3493,10 @@ class RideLifecycleController extends GetxController {
|
|||||||
hours = durationToAdd.inHours;
|
hours = durationToAdd.inHours;
|
||||||
minutes = (durationToAdd.inMinutes % 60).round();
|
minutes = (durationToAdd.inMinutes % 60).round();
|
||||||
|
|
||||||
if (polyLines.isNotEmpty) mapEngine.clearPolyline();
|
if (polyLines.isNotEmpty) {
|
||||||
|
mapEngine.clearPolyline();
|
||||||
|
await Future<void>.delayed(Duration.zero);
|
||||||
|
}
|
||||||
|
|
||||||
rideConfirm = false;
|
rideConfirm = false;
|
||||||
isMarkersShown = true;
|
isMarkersShown = true;
|
||||||
@@ -3501,28 +3507,19 @@ class RideLifecycleController extends GetxController {
|
|||||||
await mapEngine.playRouteAnimation(
|
await mapEngine.playRouteAnimation(
|
||||||
mapEngine.polylineCoordinates, mapEngine.lastComputedBounds);
|
mapEngine.polylineCoordinates, mapEngine.lastComputedBounds);
|
||||||
|
|
||||||
// ✅ FIX P1: انتظار تحميل الأيقونات قبل إنشاء الـ markers
|
// بناء Set كاملة دفعة واحدة ثم تعيينها
|
||||||
// intaleq_maps تتطلب صوراً مسجلة عبر addImage() وليس أصولاً مباشرة
|
final Set<Marker> newMarkers = {
|
||||||
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 = {
|
|
||||||
Marker(
|
Marker(
|
||||||
markerId: const MarkerId('start'),
|
markerId: const MarkerId('start'),
|
||||||
position: startLoc,
|
position: startLoc,
|
||||||
icon: InlqBitmap.fromStyleImage(mapEngine.startIcon),
|
icon: InlqBitmap.fromAsset('assets/images/A.png'),
|
||||||
infoWindow: const InfoWindow(title: 'A'),
|
infoWindow: const InfoWindow(title: 'A'),
|
||||||
anchor: const Offset(0.5, 1.0),
|
anchor: const Offset(0.5, 1.0),
|
||||||
),
|
),
|
||||||
Marker(
|
Marker(
|
||||||
markerId: const MarkerId('end'),
|
markerId: const MarkerId('end'),
|
||||||
position: endLoc,
|
position: endLoc,
|
||||||
icon: InlqBitmap.fromStyleImage(mapEngine.endIcon),
|
icon: InlqBitmap.fromAsset('assets/images/b.png'),
|
||||||
infoWindow: const InfoWindow(title: 'B'),
|
infoWindow: const InfoWindow(title: 'B'),
|
||||||
anchor: const Offset(0.5, 1.0),
|
anchor: const Offset(0.5, 1.0),
|
||||||
),
|
),
|
||||||
@@ -3532,11 +3529,12 @@ class RideLifecycleController extends GetxController {
|
|||||||
final wp = menuWaypoints[i];
|
final wp = menuWaypoints[i];
|
||||||
if (wp != null) {
|
if (wp != null) {
|
||||||
final bool isFirstWaypoint = i == 0;
|
final bool isFirstWaypoint = i == 0;
|
||||||
markers.add(Marker(
|
newMarkers.add(Marker(
|
||||||
markerId: MarkerId('waypoint_$i'),
|
markerId: MarkerId('waypoint_$i'),
|
||||||
position: wp,
|
position: wp,
|
||||||
icon: InlqBitmap.fromStyleImage(
|
icon: InlqBitmap.fromAsset(isFirstWaypoint
|
||||||
isFirstWaypoint ? mapEngine.startIcon : mapEngine.endIcon),
|
? 'assets/images/A.png'
|
||||||
|
: 'assets/images/b.png'),
|
||||||
infoWindow:
|
infoWindow:
|
||||||
InfoWindow(title: isFirstWaypoint ? 'Stop 1' : 'Stop 2'),
|
InfoWindow(title: isFirstWaypoint ? 'Stop 1' : 'Stop 2'),
|
||||||
anchor: const Offset(0.5, 1.0),
|
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');
|
// تعيين الـ markers مباشرة في mapEngine (بدون setter لتجنب update() مضاعف)
|
||||||
update();
|
mapEngine.markers = newMarkers;
|
||||||
|
Log.print(
|
||||||
|
'✅ FIX P1 v2: ${newMarkers.length} markers placed — start: $startLoc, end: $endLoc');
|
||||||
|
mapEngine.update();
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
if (isDrawingRoute) {
|
if (isDrawingRoute) {
|
||||||
isDrawingRoute = false;
|
isDrawingRoute = false;
|
||||||
@@ -3805,9 +3806,11 @@ class RideLifecycleController extends GetxController {
|
|||||||
if (response is Map<String, dynamic>) {
|
if (response is Map<String, dynamic>) {
|
||||||
final data = response['data'];
|
final data = response['data'];
|
||||||
if (data is String) return 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 {
|
} else {
|
||||||
Log.print("⚠️ getRideStatus: response is not a Map, got: ${response.runtimeType}");
|
Log.print(
|
||||||
|
"⚠️ getRideStatus: response is not a Map, got: ${response.runtimeType}");
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user