mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix speed and heading crashes
Separate method for overlays
This commit is contained in:
parent
d27123a49a
commit
377eeea177
2 changed files with 11 additions and 5 deletions
|
|
@ -784,10 +784,10 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
positionPacket.timestamp = UInt32(LocationHelper.currentTimestamp.timeIntervalSince1970)
|
||||
positionPacket.altitude = Int32(LocationHelper.currentAltitude)
|
||||
positionPacket.satsInView = UInt32(LocationHelper.satsInView)
|
||||
if !LocationHelper.currentSpeed.isNaN || !LocationHelper.currentSpeed.isInfinite {
|
||||
if LocationHelper.currentSpeed > 0 && (!LocationHelper.currentSpeed.isNaN || !LocationHelper.currentSpeed.isInfinite) {
|
||||
positionPacket.groundSpeed = UInt32(LocationHelper.currentSpeed * 3.6)
|
||||
}
|
||||
if (!LocationHelper.currentHeading.isNaN || !LocationHelper.currentHeading.isInfinite) {
|
||||
if LocationHelper.currentHeading > 0 && (!LocationHelper.currentHeading.isNaN || !LocationHelper.currentHeading.isInfinite) {
|
||||
positionPacket.groundTrack = UInt32(LocationHelper.currentHeading)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
#endif
|
||||
}
|
||||
|
||||
private func setMapLayer(mapView: MKMapView) {
|
||||
private func setMapBaseLayer(mapView: MKMapView) {
|
||||
// Avoid refreshing UI if selectedLayer has not changed
|
||||
guard currentMapLayer != selectedMapLayer else { return }
|
||||
currentMapLayer = selectedMapLayer
|
||||
|
|
@ -117,6 +117,10 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
default:
|
||||
mapView.mapType = .standard
|
||||
}
|
||||
}
|
||||
|
||||
private func setMapOverlays(mapView: MKMapView) {
|
||||
|
||||
// Weather radar
|
||||
if UserDefaults.enableOverlayServer {
|
||||
let locale = Locale.current
|
||||
|
|
@ -165,8 +169,10 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Set selected map layer
|
||||
setMapLayer(mapView: mapView)
|
||||
// Set selected map base layer
|
||||
setMapBaseLayer(mapView: mapView)
|
||||
// Set map overlay layer
|
||||
setMapOverlays(mapView: mapView)
|
||||
|
||||
let latest = positions
|
||||
.filter { $0.latest == true }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue