Modern Apps git

← Modern-Apps.git

maps: wire compass to live bearing with reset-north

Commit
316cae4a8466f1ac9372ab78a3f25dad20d9f0f9
Author
vayun-mathur <[email protected]>
When
2026-09-16 04:55 UTC (2 months ago)
Parents
755a105

Diff

maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt
diff --git a/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt b/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.ktindex 1a404d4899..9f9d4c4a7d 100644--- a/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt+++ b/maps/src/main/java/com/vayunmathur/maps/ui/MapContentBox.kt@@ -73,6 +73,7 @@ internal fun MapPageScope.MapContentBox(                     satelliteEnabled = satelliteEnabled,                     safetyEnabled = safetyEnabled,                     transitEnabled = transitEnabled,+                    selectedTransitStop = selectedTransitStop,                     darkBasemap = darkMap,                 ) @@ -183,11 +184,11 @@ internal fun MapPageScope.MapContentBox(                      // Browse controls, plus the layers and settings buttons, which stay out while                     // a place is selected and ride above the sheet — see [MapFabStack].-                    // GAP (deferred, camera is target+zoom only): bearing is always 0-                    // north-up, so the compass hides itself and reset-north is a no-op.+                    // The compass reads the live camera bearing: the twist gesture rotates the+                    // basemap on the overlay-free path, and tapping it animates back to north.                     MapFabStack(                         camera = camera,-                        bearing = 0.0,+                        bearing = camera.position.bearing,                         browsing = browsing,                         // Whichever of the three is occupying the bottom: at most one sheet is                         // ever up, and the search bar is only drawn when neither is.@@ -196,9 +197,13 @@ internal fun MapPageScope.MapContentBox(                         lift = {                             (if (searchBarVisible) searchBarLiftPx.toFloat() else 0f).roundToInt()                         },-                        // GAP (deferred, camera is target+zoom only): nothing to reset —-                        // the map is always north-up. Kept so the control slot survives.-                        onResetNorth = {},+                        // Reset-north: animate the bearing back to 0, keeping target/zoom/pitch.+                        // `animateTo` already interpolates the short way round.+                        onResetNorth = {+                            coroutineScope.launch {+                                camera.animateTo(camera.position.copy(bearing = 0.0))+                            }+                        },                         onLayers = { chrome.show(MapOverlay.Layers) },                         onParking = {                             val spot = parkingSpot