From e4a99510db4441b680d8595f081759fa5386e0aa Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 25 Apr 2023 23:10:08 -0700 Subject: [PATCH] put compass under mapbuttons --- Meshtastic/Views/Map/Custom/MapButtons.swift | 3 ++- Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift | 16 ++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Meshtastic/Views/Map/Custom/MapButtons.swift b/Meshtastic/Views/Map/Custom/MapButtons.swift index e7699279..a2dd3e58 100644 --- a/Meshtastic/Views/Map/Custom/MapButtons.swift +++ b/Meshtastic/Views/Map/Custom/MapButtons.swift @@ -45,7 +45,8 @@ struct MapButtons: View { .background(Color(UIColor.systemBackground)) .cornerRadius(8) .shadow(radius: 1) - .offset(x: 2, y: self.tracking == .followWithHeading ? 90 : 25) + .offset(x: 3, y: 25) + } } diff --git a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift index 57c3980b..01d418a1 100644 --- a/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift +++ b/Meshtastic/Views/Map/Custom/MapViewSwiftUI.swift @@ -78,14 +78,14 @@ struct MapViewSwiftUI: UIViewRepresentable { mapView.showsPitchControl = true #else #if os(iOS) - // Hide the default compass that only appears when you are not going north and instead always show the compass in the bottom right corner - mapView.showsCompass = true -// let compassButton = MKCompassButton(mapView: mapView) -// compassButton.compassVisibility = .adaptive -// mapView.addSubview(compassButton) -// compassButton.translatesAutoresizingMaskIntoConstraints = false -// compassButton.trailingAnchor.constraint(equalTo: mapView.trailingAnchor, constant: -5).isActive = true -// compassButton.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -25).isActive = true + // Move the default compass under the mapbuttons control + mapView.showsCompass = false + let compass = MKCompassButton(mapView: mapView) + compass.translatesAutoresizingMaskIntoConstraints = false + compass.compassVisibility = .adaptive + mapView.addSubview(compass) + compass.trailingAnchor.constraint(equalTo: mapView.trailingAnchor, constant: -5).isActive = true + compass.topAnchor.constraint(equalTo: mapView.topAnchor, constant: 145).isActive = true #endif #endif }