diff --git a/templates/index.html b/templates/index.html
index 2be6883..365e570 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -318,7 +318,41 @@ Czas pomiaru: ${current.time ? new Date(current.time).toLocaleString() : 'brak d
}
});
}
+ function getUserLocation() {
+ if (navigator.geolocation) {
+ updateResult("Pobieranie Twojej lokalizacji...");
+ navigator.geolocation.getCurrentPosition(
+ async (position) => {
+ const lat = position.coords.latitude;
+ const lon = position.coords.longitude;
+
+ setMarker(lat, lon, "Ładowanie nazwy...");
+ map.setView([lat, lon], 10);
+ try {
+ const placeName = await fetchPlaceName(lat, lon);
+ currentPlaceName = placeName;
+ setMarker(lat, lon, placeName);
+ updateResult("Ładowanie pogody...");
+ await fetchWeather(lat, lon);
+ } catch (err) {
+ updateResult("Błąd lokalizacji: " + err.message);
+ }
+ },
+ (error) => {
+ updateResult("Nie udało się uzyskać lokalizacji: " + error.message);
+ }
+ );
+ } else {
+ updateResult("Geolokalizacja nie jest obsługiwana w tej przeglądarce.");
+ }
+}
+
+ window.addEventListener('load', () => {
+ getUserLocation();
+});
+