0

カスタムの車/バイクの画像をユーザーの移動方向に表示したいのですが、現在の問題は、自転車がユーザーの移動方向に移動することですが、ユーザーが逆に来ると自転車も逆モードで表示されます。

以下はコードです:

- (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];
    }
    annotationView.image = [UIImage imageNamed:@"Bike.png"];
    annotationView.transform = CGAffineTransformMakeRotation(45);
    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];
    }
}
4

0 に答える 0