I want to show mkcircle at button click event.I have to calculated the zoom level of MKMapView using circle radius to make circle noticeable.Let the radius be anything small or big but mkcircle on mkmapview should be big enough as given in the screenshot.My code:
- (IBAction)showCircle:(id)sender {
long radius=[self calculateRadius];
NSLog(@"draw circle of radius=%ld",radius);
MKCircle *circle= [[MKCircle alloc]init];
circle = [MKCircle circleWithCenterCoordinate:CLLocationCoordinate2DMake([groupLat floatValue], [groupLon floatValue]) radius:radius];
[myMapView addOverlay:circle];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(CLLocationCoordinate2DMake([groupLat floatValue], [groupLon floatValue]), 800, 800);
//calculate zoom level
double radius = [circle radius] + [circle radius] / 2;
double scale = radius / 500;
zoomLevel=(16 - log(scale) / log(2));
region.span.latitudeDelta =zoomLevel;
region.span.longitudeDelta =zoomLevel;
[myMapView setRegion:region animated:YES];
//problem is circle looks very small and outside space is more
Any suggestions would be appreciated. thank you!
I know its old post, But replying any way.. Code in Swift 5, Xcode 11
Or we can add some margin easily by the following way