How to show locations of friends on map near by 20 km from user current location in ios [closed]

不打扰是莪最后的温柔 提交于 2019-12-08 14:24:22

问题


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:


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:


来源:https://stackoverflow.com/questions/33219544/how-to-show-locations-of-friends-on-map-near-by-20-km-from-user-current-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!