I am a new user in the iPhone application. I wanted to show pins in my MKMapView. How can i do it?
Give me some valuable suggestions.
I am a new user in the iPhone application. I wanted to show pins in my MKMapView. How can i do it?
Give me some valuable suggestions.
You need to create a delegate that implements the MKAnnotation protocol:
@interface AnnotationDelegate : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
- (id) initWithCoordinate:(CLLocationCoordinate2D)coord;
@end
@implementation AnnotationDelegate
@synthesize coordinate;
- (id) initWithCoordinate:(CLLocationCoordinate2D)coord
{
coordinate.latitude = coord.latitude;
coordinate.longitude = coord.longitude;
return self;
}
@end
For each of your map points you need to instantiate one of your AnnotionDelegate objects (passing in the coordinates of the point) and add it to the MKMapView:
AnnotationDelegate * annotationDelegate = [[[AnnotationDelegate alloc] initWithCoordinate:coordinate] autorelease];
[self._mapView addAnnotation:annotationDelegate];