change to map-saas api key and env - 2026-04-12

This commit is contained in:
Hamza-Ayed
2026-04-12 02:25:44 +03:00
parent 454276d1e0
commit 0aa1f15f25
16 changed files with 14974 additions and 13857 deletions

View File

@@ -611,53 +611,56 @@ class MapPassengerController extends GetxController {
if (response.statusCode == 200) {
final responseData = json.decode(response.body);
if (responseData['code'] == 'Ok' || responseData['routes'] != null) {
var routeData = responseData['routes'][0];
// Support both old format (routes[0]) and new SaaS format (top-level)
var routeData = responseData['routes'] != null
? responseData['routes'][0]
: responseData;
// 2. تحديث المتغيرات (المسافة والوقت)
double durationSecondsRaw = (routeData['duration'] as num).toDouble();
int finalDurationSeconds =
(durationSecondsRaw * kDurationScalar).toInt();
double distanceMeters = (routeData['distance'] as num).toDouble();
// 2. تحديث المتغيرات (المسافة والوقت)
double durationSecondsRaw = (routeData['duration'] as num).toDouble();
int finalDurationSeconds =
(durationSecondsRaw * kDurationScalar).toInt();
double distanceMeters = (routeData['distance'] as num).toDouble();
timeToPassengerFromDriverAfterApplied = finalDurationSeconds;
remainingTimeToPassengerFromDriverAfterApplied = finalDurationSeconds;
distanceByPassenger = distanceMeters.toStringAsFixed(0);
timeToPassengerFromDriverAfterApplied = finalDurationSeconds;
remainingTimeToPassengerFromDriverAfterApplied = finalDurationSeconds;
distanceByPassenger = distanceMeters.toStringAsFixed(0);
// تحديث نصوص الواجهة
int minutes = (finalDurationSeconds / 60).floor();
int seconds = finalDurationSeconds % 60;
stringRemainingTimeToPassenger =
'$minutes:${seconds.toString().padLeft(2, '0')}';
// تحديث نصوص الواجهة
int minutes = (finalDurationSeconds / 60).floor();
int seconds = finalDurationSeconds % 60;
stringRemainingTimeToPassenger =
'$minutes:${seconds.toString().padLeft(2, '0')}';
Log.print(
'✅ Driver Route Info: $minutes min, ${distanceMeters.toInt()} m');
Log.print(
'✅ Driver Route Info: $minutes min, ${distanceMeters.toInt()} m');
// 3. معالجة الرسم (Polyline)
String pointsString = routeData['geometry'] ?? "";
if (pointsString.isNotEmpty) {
List<LatLng> decodedPoints =
await compute(decodePolylineIsolate, pointsString);
// حفظ نسخة للمقارنة
_currentDriverRoutePoints = decodedPoints;
// إزالة خط مسار السائق القديم فقط
polyLines = polyLines.where((p) => p.lineOpacity != 0.999).toList();
// 3. معالجة الرسم (Polyline)
// SaaS uses 'points', OSRM uses 'geometry'
String pointsString =
routeData['points'] ?? routeData['geometry'] ?? "";
if (pointsString.isNotEmpty) {
List<LatLng> decodedPoints =
await compute(decodePolylineIsolate, pointsString);
// حفظ نسخة للمقارنة
_currentDriverRoutePoints = decodedPoints;
// إزالة خط مسار السائق القديم فقط
polyLines = polyLines.where((p) => p.lineOpacity != 0.999).toList();
// إضافة الخط الجديد (بستايل مميز للسائق)
polyLines.add(LineOptions(
geometry: decodedPoints,
lineColor: '#333333', // لون مختلف عن مسار الرحلة الأساسي
lineWidth: 5,
lineOpacity: 0.999, // acting as ID
));
refreshMapElements();
}
// 4. ضبط الكاميرا لتشمل السائق والراكب
_fitCameraToPoints(driverPos, passengerPos);
update(); // تحديث واحد للكل
// إضافة الخط الجديد (بستايل مميز للسائق)
polyLines.add(LineOptions(
geometry: decodedPoints,
lineColor: '#333333', // لون مختلف عن مسار الرحلة الأساسي
lineWidth: 5,
lineOpacity: 0.999, // acting as ID
));
refreshMapElements();
}
// 4. ضبط الكاميرا لتشمل السائق والراكب
_fitCameraToPoints(driverPos, passengerPos);
update(); // تحديث واحد للكل
}
} catch (e) {
Log.print('❌ Error calculating driver route: $e');
@@ -6478,30 +6481,29 @@ Intaleq Team''';
double lngDest = double.parse(coordDestination[1]);
myDestination = LatLng(latDest, lngDest);
// ── 2. Routing Decision: Hybrid Strategy ──────────────────────────
final bool isSaaSRequest = activeMenuWaypointCount == 0;
// ── 2. Unified SaaS Routing Strategy ──────────────────────────
final bool isSaaSRequest = true;
Uri uri;
if (isSaaSRequest) {
// Mapping SaaS format: Query Parameters
var originCoords = origin.split(',');
final Map<String, String> queryParams = {
'fromLat': originCoords[0].trim(),
'fromLng': originCoords[1].trim(),
'toLat': latDest.toString(),
'toLng': lngDest.toString(),
};
uri =
Uri.parse(AppLink.mapSaasRoute).replace(queryParameters: queryParams);
} else {
// Legacy OSRM format for multi-waypoint support
var originCoords = origin.split(',');
String waypointCoords = _buildOsrmWaypointCoords();
String osrmUrl =
'${AppLink.routesOsm}/route/v1/driving/${originCoords[1]},${originCoords[0]}$waypointCoords;$lngDest,$latDest';
uri = Uri.parse('$osrmUrl?steps=false&overview=full');
var originCoords = origin.split(',');
final Map<String, String> queryParams = {
'fromLat': originCoords[0].trim(),
'fromLng': originCoords[1].trim(),
'toLat': latDest.toString(),
'toLng': lngDest.toString(),
};
// Add multi-stop waypoints to the query parameters
for (int i = 0; i < activeMenuWaypointCount; i++) {
final wp = menuWaypoints[i];
if (wp != null) {
queryParams['stop${i + 1}Lat'] = wp.latitude.toString();
queryParams['stop${i + 1}Lng'] = wp.longitude.toString();
}
}
uri = Uri.parse(AppLink.mapSaasRoute).replace(queryParameters: queryParams);
Log.print(
'Requesting Route URI (${isSaaSRequest ? "SaaS" : "OSRM"}, Attempt: ${attemptCount + 1}): $uri');