Skip to content

Instantly share code, notes, and snippets.

@tlivings
Last active September 23, 2015 21:38
Show Gist options
  • Select an option

  • Save tlivings/620054 to your computer and use it in GitHub Desktop.

Select an option

Save tlivings/620054 to your computer and use it in GitHub Desktop.
Example of zooming to user location in MKMapView when location annotation appears
- (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