Last active
September 23, 2015 21:38
-
-
Save tlivings/620054 to your computer and use it in GitHub Desktop.
Example of zooming to user location in MKMapView when location annotation appears
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (void)mapView:(MKMapView *)mv didAddAnnotationViews:(NSArray *)views { | |
| for(MKAnnotationView *annotationView in views) { | |
| if(annotationView.annotation == mv.userLocation) { | |
| MKCoordinateRegion region; | |
| MKCoordinateSpan span; | |
| span.latitudeDelta=0.05; | |
| span.longitudeDelta=0.05; | |
| CLLocationCoordinate2D location=mv.userLocation.coordinate; | |
| location = mv.userLocation.location.coordinate; | |
| region.span=span; | |
| region.center=location; | |
| [mv setRegion:region animated:TRUE]; | |
| [mv regionThatFits:region]; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment