CLLocation Category for Calculating Bearing w/ Haversine function

Your code seems fine to me. Nothing wrong with the calculous. You don’t specify how far off your results are, but you might try tweaking your radian/degrees converters to this: double DegreesToRadians(double degrees) {return degrees * M_PI / 180.0;}; double RadiansToDegrees(double radians) {return radians * 180.0/M_PI;}; If you are getting negative bearings, add 2*M_PI to … Read more

Moving a CLLocation by x meters

A conversion to Swift, taken from this answer: func locationWithBearing(bearingRadians:Double, distanceMeters:Double, origin:CLLocationCoordinate2D) -> CLLocationCoordinate2D { let distRadians = distanceMeters / (6372797.6) // earth radius in meters let lat1 = origin.latitude * M_PI / 180 let lon1 = origin.longitude * M_PI / 180 let lat2 = asin(sin(lat1) * cos(distRadians) + cos(lat1) * sin(distRadians) * cos(bearingRadians)) let … Read more

How to find your current location with CoreLocation

You can find your location using CoreLocation like this: import CoreLocation: #import <CoreLocation/CoreLocation.h> Declare CLLocationManager: CLLocationManager *locationManager; Initialize the locationManager in viewDidLoad and create a function that can return the current location as an NSString: – (NSString *)deviceLocation { return [NSString stringWithFormat:@”latitude: %f longitude: %f”, locationManager.location.coordinate.latitude, locationManager.location.coordinate.longitude]; } – (void)viewDidLoad { locationManager = [[CLLocationManager alloc] … Read more

Background Location Services not working in iOS 7

Here is the solution that I used to get continuous location from iOS 7 devices no matter it is in foreground or background. You may find the full solution and explanation from blog and also github:- Background Location Update Programming for iOS 7 and 8 Github Project: Background Location Update Programming for iOS 7 and … Read more