だから私は3つのことをしようとしています。
- 私の場所を示す地図を持っています。
- 3D 感を出すために、マップを少し傾ける必要があります。Apple マップを 2 本の指で上下にスクロールするのと同じです。
- コンパスを使って地図を回転させます。
マップで userTrackingMode を有効にすると、マップはコンパスで回転しますが、マップに MKMapCamera を設定するとコンパスが機能しません。
これが私のコードです。
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
mapView.setUserTrackingMode(.FollowWithHeading, animated: true)
locationManager.startUpdatingLocation()
}
func locationManager(manager: CLLocationManager, didUpdateToLocation newLocation: CLLocation, fromLocation oldLocation: CLLocation) {
let userCordinate = CLLocationCoordinate2D(latitude: newLocation.coordinate.latitude, longitude: newLocation.coordinate.longitude)
let eyeCordinate = CLLocationCoordinate2D(latitude: newLocation.coordinate.latitude - 0.021078, longitude: newLocation.coordinate.longitude - 0.04078 )
let mapCamera = MKMapCamera(lookingAtCenterCoordinate: userCordinate, fromEyeCoordinate: eyeCordinate, eyeAltitude: 1400)
mapView.setCamera(mapCamera, animated: true)
print("Camera set")
}
ここで何が間違っていますか?