MKMapView с отслеживанием пользователя и камерой
Я пытаюсь реализовать навигацию с помощью MapKit. Где я инициализировал MKMapView и установил MKUserTrackingMode после загрузки карты. И пытается установить высоту и высоту камеры. Когда я запускаю приложение, карта не движется плавно. Вот мой код
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
mapView.isPitchEnabled = false
mapView.isZoomEnabled = false
if Platform.isSimulator {
LocationManager.shared.startLocationServices()
}
}
func mapView(_ mapView: MKMapView, didUpdate userLocation: MKUserLocation) {
let camera = mapView.camera
camera.altitude = 100.0
camera.pitch = 80.0
camera.centerCoordinate = userLocation.coordinate
camera.heading = (userLocation.location?.course)!//need to check option
mapView.setCamera(camera, animated: true)
}
func mapViewDidFinishLoadingMap(_ mapView: MKMapView) {
if !isLoaded {
isLoaded = true
mapView.setUserTrackingMode(MKUserTrackingMode.follow, animated: true)
mapView.showsUserLocation = true
}
}
Пожалуйста, помогите сделать это.