上記の投稿のすべてのリンクを組み合わせることで、GoogleMaps iOS SDK をローテーションしようとする試みがあり、私にとってはうまくいきました
最初にCLLocationManager
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate=self;
locationManager.desiredAccuracy=kCLLocationAccuracyBest;
locationManager.distanceFilter=kCLDistanceFilterNone;
[locationManager startUpdatingLocation];
[locationManager startUpdatingHeading];
見出しが変更されるたびに、CLLocationManager
のメソッドを使用しstartUpdatingHeading
てデリゲート メソッドを呼び出します 。- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
次のコードを使用して、見出しに従ってマップを回転させることができます。
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
double heading = newHeading.trueHeading;
double headingDegrees = (heading*M_PI/180);
CLLocationDirection trueNorth = [newHeading trueHeading];
[mapView_ animateToBearing:trueNorth];
}