(Using iOS 5 and Xcode 4.2)
I have an MKMapView and want to draw a circle of 1000m radius around the user location.
On the surface it would seem tha
I didn't understand benwad answer. So here is clearer answer:
It's pretty easy to add a circle. Conform to MKMapViewDelegate
@interface MyViewController : UIViewController
@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@end
In viewDidLoad, Create a circle annotation and add it to the map:
CLLocationCoordinate2D center = {39.0, -74.00};
// Add an overlay
MKCircle *circle = [MKCircle circleWithCenterCoordinate:center radius:150000];
[self.mapView addOverlay:circle];
Then implement mapView:viewForOverlay: to return the view.
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id)overlay
{
MKCircleView *circleView = [[MKCircleView alloc] initWithOverlay:overlay];
[circleView setFillColor:[UIColor redColor]];
[circleView setStrokeColor:[UIColor blackColor]];
[circleView setAlpha:0.5f];
return circleView;
}
But if you want the circle to always be the same size, no matter the zoom level, you'll have to do something different. Like you say, in regionDidChange:animated:, get the latitudeDelta, then create a new circle (with a radius that fits into the width), remove the old one and add the new one.
Note from me: don't forget to connect mapview with your view controller delegate. Otherwise viewForOverlay won't be called.