我希望在20公里范围内获取我的朋友的位置.App应该跟踪我当前的位置,当我想在20公里内搜索朋友时,它应该在地图上显示我所有朋友的位置。
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
[locationManager startUpdatingLocation];
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"OldLocation %f %f", oldLocation.coordinate.latitude, oldLocation.coordinate.longitude);
NSLog(@"NewLocation %f %f", newLocation.coordinate.latitude, newLocation.coordinate.longitude);
}
答案 0 :(得分:1)
查看
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations;
并使用它来获取您当前的位置:
[locations lastObject];
并且要远距离使用它:
distanceFromLocation: