MKMapView center and zoom in

后端 未结 9 1580
一向
一向 2021-02-19 23:16

I am using MKMapView on a project and would like to center the map on a coordinate and zoom in. Just like Google maps has:

GMSCameraPosition.camera(withLatitude:         


        
9条回答
  •  花落未央
    2021-02-19 23:54

    You'd create a MKCoordinateRegion object and set that as the region on your MKMapView object.

    MKCoordinateRegion mapRegion;   
    CLLocationCoordinate2D coordinate;
    coordinate.latitude = 0;
    coordinate.longitude = 0;    
    mapRegion.center = coordinate;
    mapRegion.span.latitudeDelta = 0.2;
    mapRegion.span.longitudeDelta = 0.2;
    
    [mapView setRegion:mapRegion animated: YES];
    

提交回复
热议问题