I did not understand the answer of benwad. So here is a clearer answer :
Pretty easy to add a circle. Compliant with MKMapViewDelegate
@interface MyViewController : UIViewController <MKMapViewDelegate> @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};
Then do mapView: viewForOverlay: to return the view.
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id<MKOverlay>)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, regardless of the zoom level, you will have to do something else. As you say, in regionDidChange: animated :, get latitudeDelta, then create a new circle (with a radius that fits in width), delete the old one and add a new one.
Note: Remember to associate mapview with the delegate of the view controller. Otherwise, viewForOverlay will not be called.
RealNmae Dec 21 '14 at 17:19 2014-12-21 17:19
source share