【问题标题】:In iOS get user current speed and altitude在 iOS 中获取用户当前的速度和高度
【发布时间】:2015-07-27 09:43:52
【问题描述】:

在我的应用程序中,我在地图视图中跟踪用户移动。基本上它是一个步行应用程序。现在我必须计算用户当前的步行速度和高度。我应该如何计算用户当前的速度和高度?

【问题讨论】:

    标签: ios xcode


    【解决方案1】:

    CLLocation 包含速度和高度属性。就用它吧。更多详情:

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

    【讨论】:

    • 谢谢。可以用加速度计计算速度吗?
    • 我从未尝试过,但请查看以下答案:stackoverflow.com/questions/10579004/…
    • 谢谢。我对加速度计一无所知。你能告诉我什么时候应该使用加速度计吗?请不要介意提问。
    猜你喜欢
    • 2020-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多