Hello friends

This is a simple method to add pins to a MKMapView and add an action for any indicators you have added as the rightCalloutAccessoryView.

You should implement in YourClass.h

Create an object of your custom class and use the following code
CLLocationCoordinate2D zoomLocation;
zoomLocation.latitude = [temp.hlat doubleValue];
zoomLocation.longitude =[temp.hlong doubleValue];
// 2
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 5.0*METERS_PER_MILE, 5.0*METERS_PER_MILE);
// 3
MKCoordinateRegion adjustedRegion = [map regionThatFits:viewRegion];
// 4
[map setRegion:adjustedRegion animated:YES];

MyLocation *annotation = [[MyLocation alloc] initWithName:temp.hotName address:temp.hotAddr coordinate:zoomLocation andID:temp.ofrId];

[map addAnnotation:annotation];

and implement the following delegate method to drop pins

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id )annotation {

static NSString *identifier = @"MyLocation";
if ([annotation isKindOfClass:[MyLocation class]]) {

MKPinAnnotationView *annotationView = (MKPinAnnotationView *) [map dequeueReusableAnnotationViewWithIdentifier:identifier];
if (annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
} else {
annotationView.annotation = annotation;
}
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.rightCalloutAccessoryView = infoButton;
annotationView.enabled = YES;
annotationView.canShowCallout = YES;

annotationView.pinColor = MKPinAnnotationColorGreen;
return annotationView;
}

return nil;
}

and the following method for performing actions when the rightCalloutAccessoryView is tapped

- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{

MyLocation *annotation = (MyLocation *) [view annotation];
for (hotel *htl in self.hotelsArray) {
if ([htl.ofrId isEqualToString:annotation.placeID]) {

HotelViewController *htlView = [[HotelViewController alloc] initWithNibName:@"HotelViewController" bundle:nil];
UIViewController * myController = [[self superview] firstAvailableUIViewController];
htlView.hotelID = htl.ofrId;
[[myController navigationController] pushViewController:htlView animated:YES];
}
}

}