Zoom in a MKMapView programmatically

后端 未结 9 1755
逝去的感伤
逝去的感伤 2020-12-04 13:27

I\'m using a MKMapView inside an iPhone app. When I click a button the zoom level must increase. This is my first approach:

MKCoordinateRegion z         


        
9条回答
  •  Happy的楠姐
    2020-12-04 13:56

    I have no idea if this is the right way to do it, but I'm using this to zoom in and out.

            case 0: { // Zoom In
            //NSLog(@"Zoom - IN");
            MKCoordinateRegion region;
            //Set Zoom level using Span
            MKCoordinateSpan span;  
            region.center=mapView.region.center;
    
            span.latitudeDelta=mapView.region.span.latitudeDelta /2.0002;
            span.longitudeDelta=mapView.region.span.longitudeDelta /2.0002;
            region.span=span;
            [mapView setRegion:region animated:TRUE];
        }
            break;
    
        // Zoom Out 
        case 2: {
            //NSLog(@"Zoom - OUT");
            MKCoordinateRegion region;
            //Set Zoom level using Span
            MKCoordinateSpan span;  
            region.center=mapView.region.center;
            span.latitudeDelta=mapView.region.span.latitudeDelta *2;
            span.longitudeDelta=mapView.region.span.longitudeDelta *2;
            region.span=span;
            [mapView setRegion:region animated:TRUE];
        }
    

提交回复
热议问题