Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@chakrit
Created January 12, 2012 10:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chakrit/1599700 to your computer and use it in GitHub Desktop.
Save chakrit/1599700 to your computer and use it in GitHub Desktop.
CLLocationCoordinate2D min = CLLocationCoordinate2DMake(99999.0, 99999.0);
CLLocationCoordinate2D max = CLLocationCoordinate2DMake(-99999.0, -99999.0);
// find max/min....
// zoom to cover area
// TODO: Maybe better using a MKPolygon which can calculate its own fitting region.
CLLocationCoordinate2D center = CLLocationCoordinate2DMake((max.latitude + min.latitude) / 2.0, (max.longitude + min.longitude) / 2.0);
MKCoordinateSpan span = MKCoordinateSpanMake(max.latitude - min.latitude, max.longitude - min.longitude);
MKCoordinateRegion region = MKCoordinateRegionMake(center, span);
[_mapView setRegion:[_mapView regionThatFits:region] animated:YES];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment