Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customizing the MKAnnotation Callout bubble

I have a requirement in my application map page. I have to customize the Callout bubbles. I need to add an image, two labels and a button with specific height and width of each.

I have gone through web and could not find a proper link that explains how to customize the callout bubbles. If any one of you come across or know about it please share with me.

any simple examples or links would be really great.

Thanks in advance suresh

like image 352
sbmandav Avatar asked Nov 04 '10 06:11

sbmandav


1 Answers

An example to help you :

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{   
    MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"loc"];

    // Button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    button.frame = CGRectMake(0, 0, 23, 23);
    annotationView.rightCalloutAccessoryView = button;

    // Image and two labels
    UIView *leftCAV = [[UIView alloc] initWithFrame:CGRectMake(0,0,23,23)];
    [leftCAV addSubview : yourImageView];
    [leftCAV addSubview : yourFirstLabel];
    [leftCAV addSubview : yourSecondLabel];
    annotationView.leftCalloutAccessoryView = leftCAV;

    annotationView.canShowCallout = YES;

    return annotationView;
}

For more informations, look at this : http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html%23//apple_ref/occ/cl/MKAnnotationView

like image 127
MathieuF Avatar answered Oct 19 '22 08:10

MathieuF