2

I am creating a MKMapView app where I want to provide a user with a facility of zooming MKCircle deep inside to see annotations and at the same moment if user wants to go back to the previous zoom level to see the circle,he just need to press the same button. I'm not getting how to toggle between the zoom levels?

//in the below code I have calculated the radius of mkcircle before putting it on mkmapview

- (IBAction)adjustCircle:(id)sender{
long radius=[self calculateRadius];
NSLog(@"draw circle of radius=%ld",radius);
//int meter = 1000;
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]), 500, 500);
region.span.latitudeDelta  =[self getZoomLevel:circle];
region.span.longitudeDelta =[self getZoomLevel:circle];
[myMapView setRegion:region animated:YES];




-(int) getZoomLevel:(MKCircle*) circle {
zoomLevel = 11;

if(isShowLocPoints == YES){
    return 20;
}

if (circle != nil) {
double radius = [circle radius] + [circle radius] / 2;
double scale = radius / 500;
zoomLevel=(16 - log(scale) / log(2));
}
NSLog(@"zoom level=%d",zoomLevel);
return zoomLevel;

Thanks

sarita
  • 236
  • 1
  • 11

1 Answers1

0

you can property a BOOL value to mark iszoomed when the view did load, when user first click the button ,zoom in or zoom out, change the BOOL value, when click the button again, check the BOOL value, if true, zoom in ; if false, zoom out.

Ezatu.
  • 9
  • 1
  • thanks for the answer.I have done the same way.I'm supplying different zoom levels at button click but the problem is span of region doesn't change once it is set. – sarita Dec 28 '16 at 09:18
  • can you upload some pictures, i can't understand your problem. – Ezatu. Dec 28 '16 at 10:15