Hello,
thank you so much for your reply and help. I have actually already tried switching to MKMapView, but that would unfortunately break some other things such as reliable user following/tracking and the automated shifting between it being enabled on a button press and disabled when dragging the Map around. I know that apps even pre iOS 14 did that properly, for example I got an iPhone 7 with iOS 12 running an older, still supported version of the Geocaching app which has map switching and proper tracking / user following.
For context here's how my tracking works. I basically got a Location Manager class with the needed functions that looks like this (plus a few extra functions like getting authorization to use the location that are irrelevant for this problem):
class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
private let locationManager = CLLocationManager()
private var hasCenteredOnUser = false
@Published var authorizationStatus: CLAuthorizationStatus = .notDetermined
// Centre Germany
@Published var region = MKCoordinateRegion(
center: CLLocationCoordinate2D(
latitude: 51,
longitude: 10.5),
span: MKCoordinateSpan(
latitudeDelta: 9,
longitudeDelta: 9))
override init() {
super.init()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let location = locations.last else { return }
if !hasCenteredOnUser {
DispatchQueue.main.async {
self.region = MKCoordinateRegion(
center: location.coordinate,
span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)
)
self.hasCenteredOnUser = true
}
}
}
//For the button to get the location
func getCurrentLocation() -> CLLocationCoordinate2D? {
return locationManager.location?.coordinate
}
}
Honestly I can't really believe that ma switching is not possible in MapKit for SwiftUI for iOS 14, that would be crazy as it is such a simple function. You said that it doesn't re-render because it needs to be truly different. But why isn't it? Can't we maybe figure out a solution there to force it to re-render?
As I said, thanks so much already.