put compass under mapbuttons

This commit is contained in:
Garth Vander Houwen 2023-04-25 23:10:08 -07:00
parent 4f28da3240
commit e4a99510db
2 changed files with 10 additions and 9 deletions

View file

@ -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)
}
}

View file

@ -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
}