【问题标题】:Rotate image as per the direction of user follows in Map根据用户在地图中跟随的方向旋转图像
【发布时间】:2013-09-08 00:14:36
【问题描述】:

我想按照用户跟随的方向旋转自行车/汽车图像。现在图像跟随方向但看起来没有方向性,我们可以说点不跟随方向:

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

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

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

    annotationView.image = [UIImage imageNamed:@"Bike.png"];
    annotationView.annotation = annotation;

    return annotationView;
}

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
    if (newLocation.horizontalAccuracy < 0)
        return;
    if  (!newLocation)
        return;

    currentLocation = newLocation;
    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];
    }
}

【问题讨论】:

    标签: iphone ios google-maps mkmapview mapkit


    【解决方案1】:

    查看核心位置的-[CLLocationManagerDelegate locationManager:didUpdateHeading:]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-05
      • 1970-01-01
      相关资源
      最近更新 更多