Die Google Maps Integration ist für die Web-Plattform konfiguriert mit sicherem API Key Management.
-
web/index.html - Google Maps wird NICHT mehr statisch geladen (API Key ist nicht mehr öffentlich sichtbar)
-
lib/services/google_maps_initializer.dart - Neuer Service zum dynamischen Laden der Google Maps API:
- Lädt API Key aus
.envDatei (nicht öffentlich zugänglich) - Fügt Google Maps Script zur Laufzeit hinzu
- Nur auf Web-Plattform aktiv
- Lädt API Key aus
-
lib/main.dart - Initialisierung vor App-Start:
if (kIsWeb) { await GoogleMapsInitializer.initialize(); }
-
pubspec.yaml -
google_maps_flutter: ^2.10.0(inkl. Web-Plugin)
- NICHT mehr in der index.html (wäre öffentlich sichtbar)
- Wird aus
.envDatei geladen (nicht im Git Repository) - Zur Laufzeit dynamisch eingefügt
GOOGLE_MAPS_API_KEY="YOUR_API_KEY_HERE"
In der Google Cloud Console sollten Sie HTTP Referrer Restrictions setzen:
- Gehen Sie zu: https://console.cloud.google.com/apis/credentials
- Wählen Sie Ihren API Key aus
- Unter "Application restrictions" → "HTTP referrers"
- Fügen Sie hinzu:
https://yourdomain.com/*(Ihre Production Domain)http://localhost:*(für lokale Entwicklung)https://localhost:*(für lokale HTTPS-Entwicklung)
flutter run -d chromeoder für Production Build:
flutter build web- Der API Key wird NICHT mehr in der index.html gespeichert ✅
- Die
.envDatei sollte NICHT ins Git Repository committed werden - Für Production: Domain-Restrictions in Google Cloud Console setzen
- Die Google Maps JavaScript API muss in der Google Cloud Console aktiviert sein
- ✅ Marker für currentGeolocation
- ✅ Polygone für boundaries
- ✅ Zoom und Pan
- ✅ InfoWindows
- ✅ Bildschirmfüllende Map-Ansicht
- ✅ Sicherer API Key (nicht öffentlich sichtbar)
- My Location Button funktioniert nur mit HTTPS
- Einige native Features (z.B. Kompass) sind nicht verfügbar
- API Key muss in
.envvorhanden sein (wird beim ersten Aufruf geladen)