Google的API要求您初始化CLLocationManager。既然你已經有了位置管理器,你可以將你的類設置爲CLLocationManagerDelegate。這爲您提供了意味着你可以同時獲得一個確切的位置以及位置已改變
爲了得到一個確切的位置通知原生的iOS方法:
[self.locationManager requestLocation]; //Get the current location once (iOS 9 and above)
要監視的位置:
[self.locationManager startUpdatingLocation] // Ask for the current location until you call stopUpdatingLocation
// or
[self.locationManager startMonitoringSignificantLocationChanges] // Tells you when your location has greatly changed
然後您需要符合協議,該協議至少有2種方法:
- (void)locationManager:(CLLocationManager *)manager
didUpdateLocations:(NSArray<CLLocation *> *)locations
// Do anything that you need to do once you have a location update
- (void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
// Your location update failed, handle it
什麼v你有沒有收到可能性? – KENdi
@KENdi - 我收到的值在0到1之間,但最大的值不是我當前的地方。那麼我怎樣才能得到準確的可能性值? – iPatel