课程价值-1所有时间

时间:2013-09-13 13:17:33

标签: iphone ios mapkit core-location

我已将此标志设置为info.plist文件:所需的设备功能 - gps和megnetometer

但是输出日志显示课程值的所有时间-1,以下是日志:

2013-09-09 11:05:09.930 MapApp [143:907]< + 23.05910024,+ 72.53762685> +/- 65.00m(速度-1.00 mps / course -1.00)@ 09/09/13 11:05:00 AM印度标准时间

@interface MAViewController : UIViewController <MKMapViewDelegate,CLLocationManagerDelegate>
{
    CLLocation *currentLocation;
    CLLocation *previousLocation;
    CLLocationManager *callMethod;
    MyAnnotation *myAnnotation;
    MKAnnotationView *annotationView;
}
@property (nonatomic, retain) IBOutlet UIImageView *bike;

@end


- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
    static NSString *AnnotationViewID = @"annotationViewID";

    annotationView = (MKAnnotationView *)[map dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];

    if (annotationView == nil)
    {
        annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationViewID] autorelease];
    }

    NSLog("%@",currentLocation.course);

    self.bike.transform = CGAffineTransformMakeRotation(45);
    annotationView.image = self.bike.image;

    return annotationView;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    if (newLocation.horizontalAccuracy < 0)
        return;
    if  (!newLocation)
        return;
    currentLocation = newLocation;
    previousLocation = oldLocation;
    if(currentLocation != nil)
    {
        if (myAnnotation)
        {
            [self.myMapView removeAnnotation:myAnnotation];
        }
        CLLocationCoordinate2D location = CLLocationCoordinate2DMake(currentLocation.coordinate.latitude, currentLocation.coordinate.longitude);
        myAnnotation = [[MyAnnotation alloc] initWithCoordinates:location title:@"Current Location" subTitle:nil];
        [self.myMapView addAnnotation:myAnnotation];
    }
}

1 个答案:

答案 0 :(得分:1)

您的日志显示速度也无效。所以你是

或者:
- 不动 - 或者更可能的是,您不使用GPS作为定位服务:将准确度设置为CLLAccuracyBest以确保获得GPS位置。课程和速度,不适用于手机信号塔或wifi定位。