I am creating a swiftui map view with code below, I can see the blue dot for user location, but I can not see the user heading annotation (the blue fan out partially transparent image connected to the user location dot, like what is showing on apple map), is there a simple configure or function call to show it or have to customize the user location annotation?
@State private var mapCameraPosition: MapCameraPosition = .userLocation(followsHeading: true, fallback: .automatic)
var body: some View {
ZStack {
Map(position: $mapCameraPosition) {
UserAnnotation()
}
}
}
Location manager code is like:
class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
let locationManager = CLLocationManager()
@Published var currentLocation: CLLocation?
@Published var currentHeading: CLHeading?
override init() {
super.init()
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.requestWhenInUseAuthorization()
locationManager.startUpdatingLocation()
locationManager.startUpdatingHeading()
}
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
currentLocation = locations.last
}
func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) {
currentHeading = newHeading
}
}