0

在这段代码中,我收到了错误的距离,_latitude 和 _longtitude 是 NSString。有什么建议可以纠正这个吗?

CLLocationManager *locationManager = [[CLLocationManager alloc] init];
        locationManager.desiredAccuracy = kCLLocationAccuracyBest;
        [locationManager startUpdatingLocation];
        CLLocation *location = [locationManager location];

        CLLocationCoordinate2D coord;
        coord.latitude = [_latitude doubleValue];
        coord.longitude = [_longitude doubleValue];

        CLLocation *anotLocation = [[CLLocation alloc] initWithLatitude:coord.latitude longitude:coord.longitude];
        _distancia = [NSNumber numberWithFloat:([location distanceFromLocation:anotLocation]/1000)];
4

1 回答 1

0

看看这个位置控制器的单例实现

https://github.com/hackerinheels/locationcontroller

有了这个电话

    CLLocation *currLocation = [[LocationController sharedLocationInterface]getCurrentLocation];
于 2014-07-29T21:18:21.700 回答