How to show locations of friends on map near by 20

2019-06-14 20:40发布

I want to get locations of my friends near by me within 20km.App should track my current location and when i want to search for friends within 20km,It should show All my friends location on map.

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);

}

1条回答
可以哭但决不认输i
2楼-- · 2019-06-14 21:43

Look into

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations;

and use this to get your current location:

  [locations lastObject];

and to get distance use this:

  distanceFromLocation:
查看更多
登录 后发表回答