googel map routs to near gasstation

This commit is contained in:
2026-10-09 19:20:44 +02:00
parent 141999d61c
commit 832747fce6
9 changed files with 58427 additions and 57178 deletions
+23 -14
View File
@@ -9,6 +9,8 @@ class GasstationsController extends GetxController {
final isLoadingLocation = false.obs;
final errorMessage = ''.obs;
final eControlData = <EControlModel>[].obs;
double? currentLatitude;
double? currentLongitude;
@override
void onInit() {
@@ -32,19 +34,24 @@ class GasstationsController extends GetxController {
// Standort-Abfrage mit Timeout versehen (z. B. 8 Sekunden),
// falls der Browser/User bei der Rechtefreigabe blockiert oder hängt
await geolocationService
.getCurrentLocation()
.timeout(
const Duration(seconds: 8),
onTimeout: () {
throw TimeoutException('Standortabfrage hat zu lange gedauert.');
},
);
await geolocationService.getCurrentLocation().timeout(
const Duration(seconds: 8),
onTimeout: () {
throw TimeoutException('Standortabfrage hat zu lange gedauert.');
},
);
if (geolocationService.hasLocation) {
currentLatitude = geolocationService.latitude;
currentLongitude = geolocationService.longitude;
// for test only später wieder deaktivieren statische koordinaten
// currentLatitude = 47.938783246743355;
// currentLongitude = 13.762770926423814;
// ende Test only
final fuelData = await eControlService.getBothFuelData(
geolocationService.latitude,
geolocationService.longitude,
currentLatitude!,
currentLongitude!,
);
List<EControlModel> dieselStations = (fuelData['DIE'] as List)
@@ -68,7 +75,10 @@ class GasstationsController extends GetxController {
if (combinedMap.containsKey(supStation.id)) {
final existingPrices = combinedMap[supStation.id!]!.prices ?? [];
final supPrices = supStation.prices ?? [];
combinedMap[supStation.id!]!.prices = [...existingPrices, ...supPrices];
combinedMap[supStation.id!]!.prices = [
...existingPrices,
...supPrices,
];
} else {
combinedMap[supStation.id!] = supStation;
}
@@ -84,8 +94,7 @@ class GasstationsController extends GetxController {
errorMessage.value =
'Standortabfrage zeitlich überschritten. Bitte erlauben Sie den Standortzugriff im Browser.';
} catch (e) {
errorMessage.value =
'Fehler beim Laden der Daten: ${e.toString()}';
errorMessage.value = 'Fehler beim Laden der Daten: ${e.toString()}';
} finally {
// Stellt sicher, dass das Lade-Icon auf jeden Fall verschwindet
isLoading.value = false;
@@ -96,4 +105,4 @@ class GasstationsController extends GetxController {
void retry() {
_loadStationInfosList();
}
}
}