0
我有這樣的代碼:獲取我的位置與谷歌地圖迅速
override func viewDidLoad() {
super.viewDidLoad()
locationManager.delegate = self
locationManager.requestWhenInUseAuthorization()
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
}
和驗證碼:
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let userLocation = locations.last
print(userLocation)
let camera = GMSCameraPosition.cameraWithLatitude(userLocation!.coordinate.latitude,
longitude: userLocation!.coordinate.longitude, zoom: 12.5)
self.mapView.camera = camera
self.mapView.myLocationEnabled = true
// self.mapView.settings.myLocationButton = true
locationManager.stopUpdatingLocation()
}
這是較早的工作,但現在看來似乎是的LocationManager甚至沒有被因爲print語句沒有返回任何信息。代碼中沒有錯誤,我似乎無法弄清楚爲什麼函數沒有被調用。任何人都可以發現任何明顯的我失蹤的東西?
謝謝
選中此問題[SO問題](http://stackoverflow.com/questions/26192480/cannot-get-my-location-to-show-up-in-go-ogle-maps-in-ios-8?rq= ),如果它可以幫助你。 – KENdi
@KENdi不幸的是,它不是我想的那個問題。出於某種原因,該函數並沒有被調用。任何想法? – tryingtolearn