iphone: How to show different image for every pin point on MapKit?

ios, ipad, iphone, mapkit, objective-c

Solution

I got that ... thanks for all who tried to help me out. the Complete solution is

Create a class

 @interface MyAnnotationClass : NSObject <MKAnnotation> {
        NSString *_name;
        NSString *_description;
        CLLocationCoordinate2D _coordinate;


    }
    @property (nonatomic, retain) NSString *name;
    @property (nonatomic, retain) NSString *description;
    @property (nonatomic, readonly) CLLocationCoordinate2D coordinate;

    -(id) initWithCoordinate:(CLLocationCoordinate2D) coordinate;

ViewDidLoad method code :

mapView.delegate = self;
    //Initialize annotation
    MyAnnotationClass *commuterLotAnnotation=[[MyAnnotationClass alloc] initWithCoordinate:CLLocationCoordinate2DMake( 39.047752, -76.850388)];
    commuterLotAnnotation.name = @"1";
    MyAnnotationClass *overflowLotAnnotation=[[MyAnnotationClass alloc] initWithCoordinate:CLLocationCoordinate2DMake(  39.047958, -76.852520)];
    overflowLotAnnotation.name = @"2";

    //Add them to array
    self.myAnnotations=[NSArray arrayWithObjects:commuterLotAnnotation, overflowLotAnnotation, nil];

    //Release the annotations now that they've been added to the array
    [commuterLotAnnotation release];
    [overflowLotAnnotation release];

    //add array of annotations to map
    [mapView addAnnotations:_myAnnotations];

viewForAnnotation code :

-(MKAnnotationView *)mapView:(MKMapView *)MapView viewForAnnotation:(id<MKAnnotation>)annotation{
    static NSString *parkingAnnotationIdentifier=@"ParkingAnnotationIdentifier";

    if([annotation isKindOfClass:[MyAnnotationClass class]]){

        //Try to get an unused annotation, similar to uitableviewcells
        MKAnnotationView *annotationView=[MapView dequeueReusableAnnotationViewWithIdentifier:parkingAnnotationIdentifier];
        //If one isn't available, create a new one
        if(!annotationView){
            annotationView=[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:parkingAnnotationIdentifier];
            if([((MyAnnotationClass *)annotation).name isEqualToString: @"1"]){
                annotationView.image=[UIImage imageNamed:@"passenger.png"];
            }
            else if([((MyAnnotationClass *)annotation).name isEqualToString: @"2"]){
                annotationView.image=[UIImage imageNamed:@"place.png"];
            }                                   
        }
        return annotationView;
    }
    return nil;
}

This is how you can add separate image for every point on MapKit.

Problem

I want to put Start and End image with overlay in an iPhone/iPad application. I have start and end Lattitude and Longitude values and want to draw overlay between start and end points and put start image on Start point and End Image on End point. I have googled but What I found is MapKit gets one image and set it on both Start and End points, could not find any help for 2nd image. like ``` annotationView.image=[UIImage imageNamed:@"parkingIcon.png"]; ``` It only set one image for both start and end points. But I want to put different images for both points. Please help.

Original source