私は解決策を見つけました:
利用可能な見出し情報を使用して地図を回転させます
[mapView setTransform:CGAffineTransformMakeRotation(heading.magneticHeading * M_PI / -180.0)];
したがって、「ビーム」は常にデバイスの上部を指します。マップの上に ImageView を表示し、locationManager:didUpdateToLocation:fromLocation: の位置を変更するだけです。
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
// scroll to new location
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(newLocation.coordinate, 2000, 2000);
[self.mapView setRegion:region animated:YES];
// set position of "beam" to position of blue dot
self.headingAngleView.center = [self.mapView convertCoordinate:newLocation.coordinate toPointToView:self.view];
// slightly adjust position of beam
self.headingAngleView.frameTop -= self.headingAngleView.frameHeight/2 + 8;
}
ここで、frameTop と frameHeight は、frame.origin.y と frame.size.height のショートカットです。理想的ではなく、ドットの位置が変わると少し欠けることがありますが、うまくいくソリューションに満足しています。
これをすべて行う私の OpenSource フレームワーク MTLocation を見てください (および他の多くのクールなマップ関連のもの):
MT場所