mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Fix ground speed calculation
Don't let the map idle Don't show navigation arrow if tracking with heading is on
This commit is contained in:
parent
a945577b89
commit
cf276bbf99
3 changed files with 64 additions and 59 deletions
|
|
@ -814,7 +814,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, ObservableObject {
|
|||
positionPacket.altitude = Int32(LocationHelper.currentAltitude)
|
||||
positionPacket.satsInView = UInt32(LocationHelper.satsInView)
|
||||
if LocationHelper.currentSpeed >= 0 {
|
||||
positionPacket.groundSpeed = UInt32(LocationHelper.currentSpeed)
|
||||
positionPacket.groundSpeed = UInt32(LocationHelper.currentSpeed * 3.6)
|
||||
}
|
||||
if LocationHelper.currentHeading >= 0 {
|
||||
positionPacket.groundTrack = UInt32(LocationHelper.currentHeading)
|
||||
|
|
|
|||
|
|
@ -115,36 +115,35 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
mapView.removeAnnotations(mapView.annotations)
|
||||
mapView.addAnnotations(waypoints)
|
||||
mapView.setUserTrackingMode(UserTrackingModes(rawValue: userTrackingModeId )?.MKUserTrackingModeValue() ?? MKUserTrackingMode.none, animated: true)
|
||||
|
||||
|
||||
let annotationCount = waypoints.count + positions.count
|
||||
if annotationCount != mapView.annotations.count {
|
||||
mapView.removeAnnotations(mapView.annotations)
|
||||
mapView.addAnnotations(waypoints)
|
||||
mapView.setUserTrackingMode(UserTrackingModes(rawValue: userTrackingModeId )?.MKUserTrackingModeValue() ?? MKUserTrackingMode.none, animated: true)
|
||||
}
|
||||
switch centeringMode {
|
||||
case .allAnnotations:
|
||||
mapView.addAnnotations(positions)
|
||||
if recenter {
|
||||
mapView.fitAllAnnotations()
|
||||
if annotationCount != mapView.annotations.count {
|
||||
mapView.addAnnotations(positions)
|
||||
if recenter {
|
||||
mapView.fitAllAnnotations()
|
||||
}
|
||||
}
|
||||
case .allPositions:
|
||||
if recenter {
|
||||
mapView.fit(annotations: positions, andShow: true)
|
||||
} else {
|
||||
mapView.addAnnotations(positions)
|
||||
if annotationCount != mapView.annotations.count {
|
||||
if recenter {
|
||||
mapView.fit(annotations: positions, andShow: true)
|
||||
} else {
|
||||
mapView.addAnnotations(positions)
|
||||
}
|
||||
}
|
||||
case .phoneGps:
|
||||
mapView.addAnnotations(positions)
|
||||
if annotationCount != mapView.annotations.count {
|
||||
mapView.addAnnotations(positions)
|
||||
}
|
||||
mapView.showsUserLocation = true
|
||||
|
||||
if recenter {
|
||||
// create a 3D Camera
|
||||
// let mapCamera = MKMapCamera()
|
||||
// mapCamera.centerCoordinate = LocationHelper.currentLocation
|
||||
// mapCamera.pitch = 45
|
||||
// mapCamera.altitude = 500 // example altitude
|
||||
// mapCamera.heading = 45
|
||||
// // set the camera property
|
||||
// mapView.camera = mapCamera
|
||||
|
||||
mapView.centerCoordinate = LocationHelper.currentLocation
|
||||
}
|
||||
}
|
||||
|
|
@ -240,10 +239,14 @@ struct MapViewSwiftUI: UIViewRepresentable {
|
|||
formatter.locale = Locale.current
|
||||
subtitle.text! += "Speed: \(formatter.string(from: Measurement(value: Double(positionAnnotation.speed), unit: UnitSpeed.kilometersPerHour))) \n"
|
||||
}
|
||||
if pf.contains(.Heading) {
|
||||
if pf.contains(.Heading){
|
||||
|
||||
annotationView.glyphImage = UIImage(systemName: "location.north.fill")?.rotate(radians: Float(degreesToRadians(Double(positionAnnotation.heading))))
|
||||
subtitle.text! += "Heading: \(String(positionAnnotation.heading)) \n"
|
||||
if parent.userTrackingModeId != 2 {
|
||||
annotationView.glyphImage = UIImage(systemName: "location.north.fill")?.rotate(radians: Float(degreesToRadians(Double(positionAnnotation.heading))))
|
||||
subtitle.text! += "Heading: \(String(positionAnnotation.heading)) \n"
|
||||
} else {
|
||||
annotationView.glyphImage = UIImage(systemName: "flipphone")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
annotationView.glyphImage = UIImage(systemName: "flipphone")
|
||||
|
|
|
|||
|
|
@ -55,9 +55,9 @@ struct NodeMap: View {
|
|||
)
|
||||
@State private var overlays: [MapViewSwiftUI.Overlay] = []
|
||||
|
||||
var body: some View {
|
||||
|
||||
NavigationStack {
|
||||
var body: some View {
|
||||
|
||||
NavigationStack {
|
||||
ZStack {
|
||||
|
||||
MapViewSwiftUI(onLongPress: { coord in
|
||||
|
|
@ -74,12 +74,12 @@ struct NodeMap: View {
|
|||
presentingWaypointForm = true
|
||||
}
|
||||
}, positions: Array(positions),
|
||||
waypoints: Array(waypoints),
|
||||
mapViewType: mapType,
|
||||
centeringMode: mapCenteringMode,
|
||||
centerOnPositionsOnly: false,
|
||||
customMapOverlay: self.customMapOverlay,
|
||||
overlays: self.overlays
|
||||
waypoints: Array(waypoints),
|
||||
mapViewType: mapType,
|
||||
centeringMode: mapCenteringMode,
|
||||
centerOnPositionsOnly: false,
|
||||
customMapOverlay: self.customMapOverlay,
|
||||
overlays: self.overlays
|
||||
)
|
||||
VStack {
|
||||
Spacer()
|
||||
|
|
@ -101,10 +101,10 @@ struct NodeMap: View {
|
|||
.presentationDragIndicator(.automatic)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
.navigationBarItems(leading:
|
||||
MeshtasticLogo(), trailing:
|
||||
ZStack {
|
||||
MeshtasticLogo(), trailing:
|
||||
ZStack {
|
||||
ConnectedDevice(
|
||||
bluetoothOn: bleManager.isSwitchedOn,
|
||||
deviceConnected: bleManager.connectedPeripheral != nil,
|
||||
|
|
@ -117,28 +117,30 @@ struct NodeMap: View {
|
|||
self.bleManager.userSettings = userSettings
|
||||
mapCenteringMode = CenteringMode(rawValue: meshMapCenteringMode) ?? CenteringMode.allAnnotations
|
||||
switch meshMapType {
|
||||
case "standard":
|
||||
mapType = .standard
|
||||
break
|
||||
case "mutedStandard":
|
||||
mapType = .mutedStandard
|
||||
break
|
||||
case "hybrid":
|
||||
mapType = .hybrid
|
||||
break
|
||||
case "hybridFlyover":
|
||||
mapType = .hybridFlyover
|
||||
break
|
||||
case "satellite":
|
||||
mapType = .satellite
|
||||
break
|
||||
case "satelliteFlyover":
|
||||
mapType = .satelliteFlyover
|
||||
break
|
||||
default:
|
||||
mapType = .hybridFlyover
|
||||
case "standard":
|
||||
mapType = .standard
|
||||
break
|
||||
case "mutedStandard":
|
||||
mapType = .mutedStandard
|
||||
break
|
||||
case "hybrid":
|
||||
mapType = .hybrid
|
||||
break
|
||||
case "hybridFlyover":
|
||||
mapType = .hybridFlyover
|
||||
break
|
||||
case "satellite":
|
||||
mapType = .satellite
|
||||
break
|
||||
case "satelliteFlyover":
|
||||
mapType = .satelliteFlyover
|
||||
break
|
||||
default:
|
||||
mapType = .hybridFlyover
|
||||
}
|
||||
})
|
||||
.onDisappear { UIApplication.shared.isIdleTimerDisabled = false }
|
||||
.onDisappear (perform: {
|
||||
UIApplication.shared.isIdleTimerDisabled = false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue