我想按照用户跟随的方向旋转自行车/汽车图像。现在图像跟随方向但看起来没有方向性,我们可以说点不跟随方向:
- (MKAnnotationView *)mapViewMKMapView *)map viewForAnnotationid <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)locationManagerCLLocationManager *)manager didUpdateToLocationCLLocation *)newLocation fromLocationCLLocation *)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];
}
}
Best Answer-推荐答案 strong>
查看核心位置的 -[CLLocationManagerDelegate locationManager:didUpdateHeading:] 。
关于iphone - 根据用户在 map 中跟随的方向旋转图像,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/18614680/
|