mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Fix compass / orient north button (#2958)
This commit is contained in:
parent
026f1607a9
commit
d6b8f07c57
3 changed files with 29 additions and 0 deletions
|
|
@ -642,6 +642,21 @@ fun MapView(
|
|||
isLocationTrackingEnabled = !isLocationTrackingEnabled
|
||||
}
|
||||
},
|
||||
onOrientNorth = {
|
||||
coroutineScope.launch {
|
||||
try {
|
||||
val currentPosition = cameraPositionState.position
|
||||
val newCameraPosition =
|
||||
CameraPosition.Builder(currentPosition)
|
||||
.bearing(0f) // Orient to north
|
||||
.build()
|
||||
cameraPositionState.animate(CameraUpdateFactory.newCameraPosition(newCameraPosition))
|
||||
debug("Oriented map to north")
|
||||
} catch (e: IllegalStateException) {
|
||||
debug("Error orienting map to north: ${e.message}")
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
if (showLayersBottomSheet) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package com.geeksville.mesh.ui.map.components
|
|||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.LocationDisabled
|
||||
import androidx.compose.material.icons.outlined.Explore
|
||||
import androidx.compose.material.icons.outlined.Layers
|
||||
import androidx.compose.material.icons.outlined.Map
|
||||
import androidx.compose.material.icons.outlined.MyLocation
|
||||
|
|
@ -52,6 +53,7 @@ fun MapControlsOverlay(
|
|||
hasLocationPermission: Boolean = false,
|
||||
isLocationTrackingEnabled: Boolean = false,
|
||||
onToggleLocationTracking: () -> Unit = {},
|
||||
onOrientNorth: () -> Unit = {},
|
||||
) {
|
||||
VerticalFloatingToolbar(
|
||||
modifier = modifier,
|
||||
|
|
@ -95,6 +97,8 @@ fun MapControlsOverlay(
|
|||
onClick = onManageLayersClicked,
|
||||
)
|
||||
|
||||
CompassButton(onOrientNorth = onOrientNorth)
|
||||
|
||||
// Location tracking button
|
||||
if (hasLocationPermission) {
|
||||
MapButton(
|
||||
|
|
@ -111,3 +115,12 @@ fun MapControlsOverlay(
|
|||
},
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun CompassButton(onOrientNorth: () -> Unit) {
|
||||
MapButton(
|
||||
icon = Icons.Outlined.Explore,
|
||||
contentDescription = stringResource(id = R.string.orient_north),
|
||||
onClick = onOrientNorth,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,6 +331,7 @@
|
|||
<string name="udp_config">UDP Config</string>
|
||||
<string name="map_node_popup_details"><![CDATA[%1$s<br>Last heard: %2$s<br>Last position: %3$s<br>Battery: %4$s]]></string>
|
||||
<string name="toggle_my_position">Toggle my position</string>
|
||||
<string name="orient_north">Orient north</string>
|
||||
<string name="user">User</string>
|
||||
<string name="channels">Channels</string>
|
||||
<string name="device">Device</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue