2

私は次のようにCLLocationマネージャーを持っています

myLocation = [[CLLocationManager alloc] init];
    myLocation.desiredAccuracy = kCLLocationAccuracyBestForNavigation ;
    myLocation.delegate=self;

デバイスが見出し情報をサポートしている場合、メソッドが呼び出されて見出しが更新されます

if([CLLocationManager headingAvailable])
        [myLocation startUpdatingHeading];

見出しの変更は以下の方法で取得します

- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
    [mymap setTransform:CGAffineTransformMakeRotation(-1 * newHeading.trueHeading * 3.14159 / 180)];

}   

この情報(newHeading.trueHeading)を使用して地図を回転させることができます。しかし、青い点(ユーザーの現在地の指標)に、与えられた精度または強制された精度で進行方向を表すセクターをどのように表示できますか。青い点のカスタム画像を使用することはできますが、その場合、光の「正確な円」が失われます。精度の円が失われないように、青い点のビューへの参照を取得して変更する方法はありますか?

また、注釈の回転は負の回転で回避できますが、マップが回転している場合、注釈の「タイトル」と「サブタイトル」は表示されている画面の表示を超えて拡張されます。それらをマップのビューに制限する方法はありますか?

事前に助けてくれてありがとう

4

2 に答える 2

1
    - (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading {
        if (newHeading.headingAccuracy > 0) {
                // [newHeading retain];
             float heading = newHeading.trueHeading >= 0 ? newHeading.trueHeading : newHeading.magneticHeading;


             [mymap setTransform:CGAffineTransformMakeRotation(heading)];


        }
    }
于 2011-09-13T14:49:40.333 に答える
1

このプロジェクトをガイドとして使用できます。mapView 全体を回転させますが、それを自分のビューに外挿することができます。

編集: userLocation アノテーションをカスタマイズする場合は、viewForAnnotation を実装し、指定されたアノテーションがそうであるかどうかを確認し、必要に応じて MKUserLocation構成されたカスタム annotationView を返す必要があります。

- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    if ([annotation isKindOfClass:[MKUserLocation class]]) {
        //Configure your custom view to point to the current heading and return it.

    }

}
于 2011-09-13T09:56:38.983 に答える