pre map passenger splitting

This commit is contained in:
Hamza-Ayed
2026-05-26 22:46:08 +03:00
parent b102af8f28
commit 118781fd66
3 changed files with 32 additions and 1 deletions

View File

@@ -3015,6 +3015,23 @@ class MapPassengerController extends GetxController {
Future<Map<String, double>?> extractCoordinatesFromLinkAsync(
String link) async {
try {
// 1. معالجة روابط الخرائط المباشرة (geo: و google.navigation:)
if (link.startsWith('geo:') || link.startsWith('google.navigation:')) {
RegExp regex = RegExp(r'(-?\d+\.\d+)[,/~=](-?\d+\.\d+)');
var match = regex.firstMatch(link);
if (match != null) {
double lat = double.parse(match.group(1)!);
double lng = double.parse(match.group(2)!);
if (lat > 40 && lat > lng) {
double temp = lat;
lat = lng;
lng = temp;
}
return {'latitude': lat, 'longitude': lng};
}
}
// 2. معالجة الروابط العادية (http/https)
int urlStartIndex = link.indexOf(RegExp(r'https?://'));
if (urlStartIndex == -1) return null;
String cleanLink = link.substring(urlStartIndex).trim();