Skip to content

Instantly share code, notes, and snippets.

@Morse-Code
Created April 29, 2013 03:04
Show Gist options
  • Save Morse-Code/5479484 to your computer and use it in GitHub Desktop.
Save Morse-Code/5479484 to your computer and use it in GitHub Desktop.
Zoom map region to current location.
- (IBAction)zoomToCurrentLocation:(id)sender
{
NSLog(@"zoomToCurrentLocation");
//Start updating location because we want it...
[_myLocationManager startUpdatingLocation];
NSLog(@"lat: %f", _myLocationManager.location.coordinate.latitude);
NSLog(@"long: %f", _myLocationManager.location.coordinate.longitude);
MKCoordinateRegion
viewRegion = MKCoordinateRegionMakeWithDistance(_myLocationManager.location.coordinate, defaultRange,
defaultRange);
[_dangerMap setRegion:viewRegion animated:YES];
//Stop updating location to save battery
[_myLocationManager stopUpdatingLocation];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment