views:

1622

answers:

1

Is it possible to have our own image instead of the default pin in MapKit map on iPhone?

I am working on an application which would show friends' locations much like Google Latitude and need to show image of friends at their locations.

It is possible using the JavaScript Google Map but i want to know if someone can give some sample code for MapKit based map.

+8  A: 

Yes it is possible. For that u have to use MKAnnotationView instead of MKPinAnnotationView. and do not use annotation.animatesDrop property.

Here are the sample code you can use in viewForAnnotation,

 annotation = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"try"];
 annotation.canShowCallout = YES;

 annotation.image = [UIImage imageNamed:@"image.png"];


 return annotation;
Jay Vachhani
Thanks. It did the trick. Cant believe i cudnt figure out such a simple trick.
Chintan Patel