diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index ca50f80d..5bad8ad4 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -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) diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index e2931d04..9213126f 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -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") diff --git a/Meshtastic/Views/Nodes/NodeMap.swift b/Meshtastic/Views/Nodes/NodeMap.swift index fd8682c2..9f51b7fe 100644 --- a/Meshtastic/Views/Nodes/NodeMap.swift +++ b/Meshtastic/Views/Nodes/NodeMap.swift @@ -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 + }) } }