OCMapView 1.0
Simple and easy to use clustering mapView.
/Users/Boti/Documents/coding/iPhone Development/OCMapView+Sample/OCMapView/OCAnnotation.m
Go to the documentation of this file.
00001 //
00002 //  OCAnnotation.m
00003 //  openClusterMapView
00004 //
00005 //  Created by Botond Kis on 14.07.11.
00006 //
00007 
00008 #import "OCAnnotation.h"
00009 
00010 @implementation OCAnnotation
00011 @synthesize coordinate;
00012 
00013 
00014 // Memory
00015 - (id)init
00016 {
00017     self = [super init];
00018     if (self) {
00019         _groupTag = title = subtitle = [[NSString stringWithFormat:@""] retain];
00020         coordinate = CLLocationCoordinate2DMake(0.0, 0.0);
00021         annotationsInCluster = [[NSMutableArray alloc] init];
00022     }
00023     
00024     return self;
00025 }
00026 
00027 - (id)initWithAnnotation:(id <MKAnnotation>) annotation{
00028     [annotation retain];
00029     
00030     self = [super init];
00031     if (self) {
00032         coordinate = [annotation coordinate];
00033         annotationsInCluster = [[NSMutableArray alloc] init];
00034         [annotationsInCluster addObject:annotation];
00035         
00036         title = [annotation.title retain];
00037         subtitle = [annotation.title retain];
00038         _groupTag = [[NSString stringWithFormat:@""] retain];
00039     }
00040     [annotation release];
00041     
00042     return self;
00043 }
00044 
00045 - (void)dealloc {
00046     [annotationsInCluster release];
00047     
00048     [title release];
00049     [subtitle release];
00050     [_groupTag release];
00051     
00052     [super dealloc];
00053 }
00054 
00055 //
00056 // List of annotations in the cluster
00057 // read only
00058 - (NSArray *)annotationsInCluster{
00059     return annotationsInCluster;
00060 }
00061 
00062 
00063 //
00064 // manipulate cluster
00065 - (void)addAnnotation:(id < MKAnnotation >)annotation{
00066     [annotation retain];
00067     
00068     // Add annotation to the cluster
00069     [annotationsInCluster addObject:annotation];
00070     [annotation release];
00071 }
00072 
00073 - (void)addAnnotations:(NSArray *)annotations{
00074     [annotations retain];
00075     for (id<MKAnnotation> annotation in annotations) {
00076         [self addAnnotation: annotation];
00077     }
00078     [annotations release];
00079 }
00080 
00081 - (void)removeAnnotation:(id < MKAnnotation >)annotation{
00082     [annotation retain];
00083     
00084     // Remove annotation from cluster
00085     [annotationsInCluster removeObject:annotation];
00086     
00087     [annotation release];
00088 }
00089 
00090 - (void)removeAnnotations:(NSArray *)annotations{
00091     [annotations retain];
00092     for (id<MKAnnotation> annotation in annotations) {
00093         [self removeAnnotation: annotation];
00094     }
00095     [annotations release];
00096 }
00097 
00098 //
00099 // protocoll implementation
00100 - (NSString *)title{
00101     return title;
00102 }
00103 
00104 - (void)setTitle:(NSString *)text{
00105     [text retain];
00106     [title release];
00107     title = text;
00108 }
00109 
00110 - (NSString *)subtitle{
00111     return subtitle;
00112 }
00113 
00114 - (void)setSubtitle:(NSString *)text{
00115     [text retain];
00116     [subtitle release];
00117     subtitle = text;
00118 }
00119 
00120 - (NSString *)groupTag{
00121     return _groupTag;
00122 }
00123 
00124 - (void)setGroupTag:(NSString *)tag{
00125     [tag retain];
00126     [_groupTag release];
00127     _groupTag = tag;
00128 }
00129 
00130 - (CLLocationCoordinate2D)coordinate{
00131     return coordinate;
00132 }
00133 
00134 - (void)setCoordinate:(CLLocationCoordinate2D)coord{
00135     coordinate = coord;
00136 }
00137 
00138 @end
 All Data Structures Files Functions Variables Enumerations Enumerator Properties