2

In my app I am tracking user movement in map view.Basically it is a walking app. Now I have to calculate user current walking speed and altitude. How should I calculate the user current speed and altitude?

rohan
  • 302
  • 3
  • 18

1 Answers1

3

CLLocation contains speed and altitude properties. Just use it. More details:

https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/index.html#//apple_ref/doc/uid/TP40007126-CH3-SW26

- (id) init
{
    self = [super init];
    if (self != nil) {
        self.manager = [[CLLocationManager alloc] init];
        self.manager.delegate = self;
        [self.manager startUpdatingLocation];
    }
    return self;
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    NSLog(@"Speed = %f", newLocation.speed);
}
Mobile Developer
  • 5,730
  • 1
  • 39
  • 45
  • Thank you. Is it possible to calculate the speed with accelerometer? – rohan Jul 27 '15 at 09:48
  • I never tried it but check this answer: http://stackoverflow.com/questions/10579004/how-to-calculate-correct-velocity-values-from-accerometer – Mobile Developer Jul 27 '15 at 09:50
  • thanks. I have no idea about accelerometer. Can u please tell me when should we use accelerometer? Please don't mind for asking the question. – rohan Jul 27 '15 at 09:52