如何获取用户当前位置。我希望跟踪用户的速度,并希望在他移动到另一个地方时绘制路径。
答案 0 :(得分:0)
您可以通过CLLocationManager获取用户当前位置:
添加以下代码获取ViewDidLoad:
CLLocationManager *objLocationManager = [[CLLocationManager alloc] init];
objLocationManager.delegate = self;
objLocationManager.desiredAccuracy = kCLLocationAccuracyBest;
[objLocationManager requestWhenInUseAuthorization];
[objLocationManager startUpdatingLocation];
以下是返回纬度和经度的委托:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
CLLocation *currentLocation = locations;
}