I'm setting region coordinates here:
// Center Map Here on initial load
#define CENTER_LATITUDE 22.11111 #fake for example
#define CENTER_LONGITUDE -23.99292 #fake for example
I'm setting the region zoom here:
MKCoordinateRegion region;
region.center.latitude = CENTER_LATITUDE;
region.center.longitude = CENTER_LONGITUDE;
region.span.latitudeDelta = SPAN_VALUE;
region.span.longitudeDelta = SPAN_VALUE;
[self.mapView setRegion:region animated:NO];
Here is my mapView didUpdateUserLocation method:
-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation
*)userLocation {
CLLocationCoordinate2D loc = [userLocation coordinate];
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(loc, 500, 500);
[self.mapView setRegion:region animated:YES];
self.mapView.centerCoordinate = userLocation.location.coordinate;
}
I know this will only zoom in on the defined region, but using something similar to this, is there a way to get the current user location and not a set predefined coordinate like the ones above?
I want the map to find current user location and then zoom to it on the map, if that makes sense.
Remember to include the LocationManager delegate within the class file
Set up your locationManager when you are ready to search for the location - from within an
IBActionmethod or evenviewDidAppearetc.Then this delegate method will fire once the location has been retrieved.
I hope this helps.