Anyone worked with MapKit's MapCameraPosition in SwiftUI?
I'm building a navigation app and ran into a limitation I can't find a clean solution for when using
.userLocation(followsHeading: true)
MapKit takes full control of the camera, smooth heading tracking, follows the user automatically. Perfect. But there's no way to set a custom pitch (tilt) on it. The only initializer available is...
.userLocation(followsHeading: true, fallback: .automatic)
No pitch, no distance parameters....
The workaround I found is setting .camera(MapCamera(..., pitch: 60)) first, waiting 200ms, then switching to .userLocation(followsHeading: true), MapKit inherits the pitch from the rendered camera state before handing off to user tracking....
It works, but it's clearly exploiting an undocumented behaviour in MapKit's state machine rather than a proper API
Has anyone found a cleaner way to achieve this? Or is UIViewRepresentable wrapping MKMapView the only proper solution?
It would be awesome to have something like this
cameraPosition = .userLocation( followsHeading: true, pitch: 60, distance: 800, fallback: .automatic )