カスタムを作成AnnotationView
:
#import <MapKit/MapKit.h>
@interface AnnotationView : MKPlacemark
@property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *subtitle;
@end
そしてで.m file
#import "AnnotationView.h"
@implementation AnnotationView
- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate addressDictionary:(NSDictionary *)addressDictionary
{
if ((self = [super initWithCoordinate:coordinate addressDictionary:addressDictionary]))
{
self.coordinate = coordinate;
}
return self;
}
@end
//関連するアノテーション追加を使用#import "AnnotationView.h"
します.m file
:
CLLocationCoordinate2D pCoordinate ;
pCoordinate.latitude = LatValue;
pCoordinate.longitude = LanValue;
// Create Obj Of AnnotationView class
AnnotationView *annotation = [[AnnotationView alloc] initWithCoordinate:pCoordinate addressDictionary:nil] ;
annotation.title = @"I m Here";
annotation.subtitle = @"This is Sub Tiitle";
[self.mapView addAnnotation:annotation];
上記は作成方法の簡単な例ですAnnotationView
。