Add map annotations, this need to use the Mkannotation this Protocol, mainly has two uilabel types of attributes, title and subtitle, when the user clicks on the heart Grow fonder needle will be displayed, such as: Google Maps implementation of the three added annotations-Tergol -Tergol's blog about the operation is like this, first define a class that inherits the Mkannotation, when the need to add annotations, based on the current region and other information, instantiate a pair of image, And then addannotation it up to GoogleMap. In order to implement mkannotation we redefine a class to operate. The NSObject class for the new objectiv-c. h header file #import <Foundation/Foundation.h> #import <CoreLocation/CoreLocation.h> # Import <MapKit/MapKit.h> @interface Mapannotations:nsobject <mkannotation>{cllocationcoordinate2d coordinate;//this, in the map, is the center point. NSString *subtitle; NSString *title; }-(ID) initwithcoordinate: (cllocationcoordinate2d) coordinate; @property (nonatomic, ReadOnly) cllocationcoordinate2d coordinate; @property (nonatomic, retain) NSString *subtitle; @property (nonatomic, retain) NSString *title; @end. m source file #import "MapAnnotations.h" @implementation mapannotations@synthesize coordinate; @synthesize title;@ Synthesize subtitle;-(ID) initwithcoordinate: (cllocationcoordinate2d) c{coordinate=c; NSLog (@ "%f,%f", C.latitude,c.longiTude); return self;} -(void) Dealloc {[Title release];[ Subtitle release]; [Super Dealloc];} @end well, with this class, we can instantiate its image in the data update, and then add it to the Mkmapview instance, as follows: Mapannotations=[[mapannotations Alloc] Initwithcoordinate:loc]; [email protected] "TEST"; [email protected] "have a try"; [Map addannotation:mapannotations]; [Mapannotations release];
IOS mkannotation Protocol add annotations to maps