我正在创建一个 MKMapView 应用程序,我想为用户提供一种在内部缩放 MKCircle 以查看注释的功能,同时如果用户想返回到先前的缩放级别以查看圆圈,他只需要按同一个按钮。我不知道如何在缩放级别之间切换?
//在下面的代码中,我已经计算了 mkcircle 的半径,然后将它放在 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;
谢谢