title: How do I add custom pins to the iPhone MapKit?
body: <p>I'm testing out the MapKit framework on the iPhone and would really much like to switch the standard pin that displays a location to an image called "location.png".</p>
  
  <p>How can I modify my code to allow that?</p>
  
  <p><b>Maincontroller</b></p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      //
      // Set the map center
      //
      CLLocationCoordinate2D coordinate;
      coordinate.latitude = 49.2802;
      coordinate.longitude = -123.1182;
      mapView.region = MKCoordinateRegionMakeWithDistance(coordinate, 2000, 2000);
  
      //
      // Set 10 random locations on the map for testing purposes
      //
      for(int i = 0; i &lt; 10; i++)
      {
          CGFloat latDelta = rand()*.035/RAND_MAX -.02;
          CGFloat longDelta = rand()*.03/RAND_MAX -.015;
  
          CLLocationCoordinate2D newCoord = { coordinate.latitude + latDelta, coordinate.longitude + longDelta };
          MapAnnotation* annotation = [[MapAnnotation alloc] initWithCoordinate:newCoord];
          [mapView addAnnotation:annotation];
          [annotation release];
      }
  
      [mapView setDelegate:self];
  }
  </code></pre>
  
  <p><b>MapAnnotation.h</b></p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  #import &lt;MapKit/MapKit.h&gt;
  
  @interface MapAnnotation : NSObject &lt;MKAnnotation&gt; {
      CLLocationCoordinate2D _coordinate;
  }
  
  - (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate;
  
  @end
  </code></pre>
  
  <p><b>MapAnnotation.m</b></p>
  
  <pre><code>#import "MapAnnotation.h"
  
  @implementation MapAnnotation
  @synthesize coordinate = _coordinate;
  
  - (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate
  {
      self = [super init];
  
      if (self != nil)
      {
          _coordinate = coordinate;
      }
  
      return self;
  }
  
  @end
  </code></pre>
  
  <p>Thank you!</p>