gpt4 book ai didi

iphone - 根据用户在 map 中跟随的方向旋转图像

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:40:46 26 4
gpt4 key购买 nike

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

- (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];
}
}

最佳答案

查看 Core Location 的 -[CLLocationManagerDelegate locationManager:didUpdateHeading:]

关于iphone - 根据用户在 map 中跟随的方向旋转图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18614680/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com