1
3つのことをやろうとしています。MKMapCameraを使用するとコンパスはMKMapViewで動作しません
- 私の所在地を示す地図があります。
- マップは、3Dの感触を与えるために少し傾いている必要があります。アップルマップ上で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")
}
私はここで間違っていますか?
誰でも助けてくれますか? –