From a31d08a2dc2e59c97f03b9affccb36bf04c33ba2 Mon Sep 17 00:00:00 2001 From: rene Date: Sat, 6 Jun 2026 20:30:22 +0200 Subject: [PATCH] Karte: Blickrichtungs-Kegel (Kompass) + ruhigeres Folgen (Rene: 'weiss nicht wo es ist/hinschaut') MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Standort-Punkt zeigt jetzt einen Kompass-KEGEL (wie Google Maps): CSS-Kegel im loc-icon (GL + Leaflet), deviceorientation mit webkitCompassHeading (iOS) bzw. 360-alpha (Android), Glaettung ueber kuerzesten Winkelweg, rAF-throttled. iOS-Permission via User-Geste (Follow-/Standort-Button startet den Kompass). - Follow pant nur noch bei brauchbarem Fix (accuracy < 75m) — ungenaue Positionen liessen die Karte zappeln; GPS-Fixes frischer (maximumAge 2s statt 5s). Marker aktualisiert weiterhin jeden Fix. Bump v1249 --- VERSION | 2 +- backend/static/css/components.css | 19 +++++++++++ backend/static/index.html | 24 +++++++------- backend/static/js/app.js | 2 +- backend/static/js/pages/map.js | 54 +++++++++++++++++++++++++++---- backend/static/landing.html | 2 +- backend/static/sw.js | 2 +- 7 files changed, 83 insertions(+), 22 deletions(-) diff --git a/VERSION b/VERSION index f0b4b2f..6d60af2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1248 \ No newline at end of file +1249 \ No newline at end of file diff --git a/backend/static/css/components.css b/backend/static/css/components.css index ce50752..8d537f5 100644 --- a/backend/static/css/components.css +++ b/backend/static/css/components.css @@ -3625,6 +3625,25 @@ html.modal-open { top: 0; left: 0; animation: loc-pulse 2s ease-out infinite; } +/* Blickrichtungs-Kegel (Kompass): JS rotiert .loc-heading um die Marker-Mitte; + sichtbar erst mit Kompass-Daten (René 2026-06-06: „weiß nicht, wo es hinschaut"). */ +.loc-heading { + position: absolute; + left: 12px; top: 12px; /* Mitte des 24×24-Icons = Rotationsachse */ + width: 0; height: 0; + display: none; + pointer-events: none; +} +.loc-heading::before { + content: ''; + position: absolute; + left: -11px; + top: -28px; /* Kegel ragt von der Mitte nach oben */ + width: 22px; + height: 24px; + background: linear-gradient(to top, rgba(59,130,246,0.55), rgba(59,130,246,0.05)); + clip-path: polygon(50% 100%, 0 0, 100% 0); /* Spitze unten (Mitte), öffnet nach oben */ +} @keyframes loc-pulse { 0% { transform: scale(0.8); opacity: 1; } 100% { transform: scale(2.2); opacity: 0; } diff --git a/backend/static/index.html b/backend/static/index.html index 83cd111..86bc87e 100644 --- a/backend/static/index.html +++ b/backend/static/index.html @@ -86,14 +86,14 @@ Ban Yaro - + - - - - - + + + + + @@ -612,11 +612,11 @@ - - - - - + + + + + @@ -626,7 +626,7 @@ - + diff --git a/backend/static/js/app.js b/backend/static/js/app.js index a62d078..d897ddd 100644 --- a/backend/static/js/app.js +++ b/backend/static/js/app.js @@ -3,7 +3,7 @@ Router, State-Management, Navigation, Initialisierung. ============================================================ */ -const APP_VER = '1248'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen +const APP_VER = '1249'; // ← bei jedem Deploy mit Frontend-Änderungen erhöhen const APP_VERSION = '1.6.0'; // ← semantische Version, wird bei make release gesetzt window.APP_VER = APP_VER; // global verfügbar für andere Module (z.B. offline-indicator) window.APP_VERSION = APP_VERSION; diff --git a/backend/static/js/pages/map.js b/backend/static/js/pages/map.js index 3932710..130dd4f 100644 --- a/backend/static/js/pages/map.js +++ b/backend/static/js/pages/map.js @@ -369,6 +369,7 @@ window.Page_map = (() => { // Follow-Mode (René 2026-06-08): Karte wandert ab jetzt mit dem Standort; // manuelles Verschieben beendet das Folgen (dragstart-Listener im Map-Init). _followGps = true; + _startCompass(); // User-Geste → iOS-Kompass-Permission _updateFollowBtn(); UI.toast.info('Karte folgt deinem Standort — zum Beenden Karte verschieben.'); } else { @@ -836,6 +837,42 @@ window.Page_map = (() => { const b = document.getElementById('map-follow-btn'); if (b) b.style.color = _followGps ? 'var(--c-primary)' : 'var(--c-text-secondary, #9ca3af)'; } + + // Kompass → Blickrichtungs-Kegel am Standort-Punkt (René 2026-06-06: „fühlt sich an, + // als ob es nicht weiß, wo es hinschaut"). iOS verlangt requestPermission in einer + // User-Geste → Start über Follow-/Standort-Button. Karte bleibt genordet (dragRotate + // aus), daher gilt: Bildschirm-Rotation des Kegels = Kompass-Heading direkt. + let _compassOn = false, _compassRaf = null; + async function _startCompass() { + if (_compassOn || !window.DeviceOrientationEvent) return; + _compassOn = true; + if (typeof DeviceOrientationEvent.requestPermission === 'function') { + try { await DeviceOrientationEvent.requestPermission(); } catch (e) {} + } + let smoothed = null; + window.addEventListener('deviceorientation', e => { + let raw = null; + if (e.webkitCompassHeading != null) raw = e.webkitCompassHeading; // iOS + else if (e.alpha != null && e.absolute !== false) raw = 360 - e.alpha; // Android + if (raw == null) return; + // Glätten über den kürzesten Winkelweg (sonst springt der Kegel bei 359↔0) + if (smoothed == null) smoothed = raw; + else { + const d = ((raw - smoothed + 540) % 360) - 180; + smoothed = (smoothed + d * 0.25 + 360) % 360; + } + if (_compassRaf) return; + _compassRaf = requestAnimationFrame(() => { + _compassRaf = null; + const cone = document.querySelector('#central-map .loc-heading'); + if (cone) { + cone.style.display = 'block'; + cone.style.transform = `rotate(${smoothed}deg)`; + } + }); + }, true); + } + function _ensureFollowBtn() { const host = document.getElementById('central-map'); if (!host || document.getElementById('map-follow-btn')) { _updateFollowBtn(); return; } @@ -853,6 +890,7 @@ window.Page_map = (() => { b.addEventListener('click', () => { if (!_userPos) { UI.toast.error('Standort noch nicht verfügbar.'); return; } _followGps = true; + _startCompass(); // User-Geste → iOS-Kompass-Permission _mapSetView(_userPos.lat, _userPos.lon, Math.max(14, Math.round(_mapGetZoom()))); _updateFollowBtn(); }); @@ -1150,14 +1188,18 @@ window.Page_map = (() => { } else { const elx = document.createElement('div'); elx.className = 'loc-icon'; - elx.innerHTML = '
'; + elx.innerHTML = '
'; _locationMarker = new maplibregl.Marker({ element: elx, anchor: 'center' }) .setLngLat([lon, lat]).addTo(_map); } - if (_followGps && !_recActive) _map.easeTo({ center: [lon, lat], duration: 600 }); + // Pan nur bei brauchbarem Fix — ungenaue Positionen (>75 m) lassen die + // Karte sonst zappeln („weiß nicht, wo es ist", René 2026-06-06). + if (_followGps && !_recActive && (pos.coords.accuracy ?? 999) < 75) { + _map.easeTo({ center: [lon, lat], duration: 600 }); + } }, () => {}, - { enableHighAccuracy: true, maximumAge: 5000, timeout: 15000 } + { enableHighAccuracy: true, maximumAge: 2000, timeout: 15000 } ); return; } @@ -1165,7 +1207,7 @@ window.Page_map = (() => { if (!window.L) return; const icon = L.divIcon({ className: 'loc-icon', - html: '
', + html: '
', iconSize: [24, 24], iconAnchor: [12, 12], }); @@ -1187,10 +1229,10 @@ window.Page_map = (() => { icon, zIndexOffset: 500, interactive: false, }).addTo(_map); } - if (_followGps && !_recActive) _map.panTo([lat, lon]); + if (_followGps && !_recActive && (pos.coords.accuracy ?? 999) < 75) _map.panTo([lat, lon]); }, () => {}, - { enableHighAccuracy: true, maximumAge: 5000, timeout: 15000 } + { enableHighAccuracy: true, maximumAge: 2000, timeout: 15000 } ); } diff --git a/backend/static/landing.html b/backend/static/landing.html index 05e1a20..65810d0 100644 --- a/backend/static/landing.html +++ b/backend/static/landing.html @@ -4,7 +4,7 @@ - + Ban Yaro — Die Hunde-App für Deutschland, Österreich & Schweiz diff --git a/backend/static/sw.js b/backend/static/sw.js index 8ba790e..0f05461 100644 --- a/backend/static/sw.js +++ b/backend/static/sw.js @@ -4,7 +4,7 @@ ============================================================ */ // ← EINZIGE Stelle für die Version — STATIC_ASSETS und CACHE_VERSION leiten sich ab -const VER = '1248'; +const VER = '1249'; const CACHE_VERSION = `by-v${VER}`; const CACHE_STATIC = `${CACHE_VERSION}-static`; const CACHE_TILES = 'ban-yaro-tiles-v1'; // bleibt über SW-Updates erhalten