My guess is why using the sample code did not work: you did not connect your view controller as a map view delegate. The first step for this is to make sure that the controller implements the MKMapViewDelegate protocol, like this (in its header file):
#import <MapKit/MapKit.h> @interface MyViewController : UIViewController <MKMapViewDelegate>
If you are creating a view controller from XIB, drag the Ctrl image from the map view onto the instance of your controller and connect it as a view on the delegate map. If you configure it in code, then call theMapView.delegate = self; in -loadView or -viewDidLoad .
Then, at some point (e.g. in -viewDidLoad ),
[theMapView addOverlay:[MKCircle circleWithCenterCoordinate:someCoordinate radius:someRadius]]
... will result in a view display calling its delegate method -mapView:viewForOverlay: which you can implement something like this:
-(MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay { MKCircleView *circleView = [[MKCircleView alloc] initWithCircle:(MKCircle *)overlay]; circleView.fillColor = [UIColor blueColor]; return [circleView autorelease]; }
source share