ビューを読み込むときにユーザーの現在の場所に注釈を追加しようとしています。それについてどうすればいいですか?私が新しいもののように事例があるといいですね。viewDidAppearでユーザーの場所を表示
ありがとうございます。
ビューを読み込むときにユーザーの現在の場所に注釈を追加しようとしています。それについてどうすればいいですか?私が新しいもののように事例があるといいですね。viewDidAppearでユーザーの場所を表示
ありがとうございます。
私は次のようでした注釈として現在位置を表示すると:
// Set up the annotation
LocationAnnotation *annotation = [[LocationAnnotation alloc] initWithLatitude:[numberFormatter numberFromString:[[location valueForKey:@"latitude"] description]] andLongitude:[numberFormatter numberFromString:[[location valueForKey:@"longitude"] description]] andTitle:[location valueForKey:@"name"] andSubtitle:[location valueForKey:@"notes"]];
[numberFormatter release];
[self.mapView addAnnotation:annotation];
注釈ヘッダクラスは次のようになります。
@interface LocationAnnotation : NSObject <MKAnnotation> {
UIImage *image;
NSNumber *latitude;
NSNumber *longitude;
NSString *locationTitle;
NSString *locationSubtitle;
}
@property (nonatomic, retain) UIImage *image;
@property (nonatomic, retain) NSNumber *latitude;
@property (nonatomic, retain) NSNumber *longitude;
@property(nonatomic,retain) NSString *locationTitle;
@property(nonatomic,retain) NSString *locationSubtitle;
-(id)initWithLatitude:(NSNumber *)aLatitude andLongitude:(NSNumber *)aLongitude andTitle:(NSString *)aLocationTitle andSubtitle:(NSString *)aLocationSubtitle;
@end
addAnnotation
方法とMKAnnotation
議定書は何」ですこれを達成するために探しています。
カスタムの場所を表示したい場合は、ここで述べたように、あなたがあなた自身のMKAnnotation
を作成する周り来ることはありませんが:
あなたMKMapView
YES
へのshowsUserLocation
プロパティを設定していることを確認します。
このプロパティのみは、がユーザーの場所の表示を有効にします。
私はこれを知っていますが、それは私が望んでいないことです。私はそれに自分の注釈を追加したい。 – deathman91
viewDidAppearでユーザーの現在の緯度と経度を取得するにはどうすればよいですか? – deathman91
現在の座標は、 'CLLocationManager'の' coordinate'プロパティで取得できます - http://developer.apple.com/library/ios/#DOCUMENTATION/CoreLocation/Reference/CLLocation_Class/CLLocation/CLLocation.html#を参照してください。 // apple_ref/doc/uid/TP40007126 –