I am trying to find the center of visible region using MapKit.
That returns the proper center. Unforunately, I can't figure out what to do in - (void)mapView
MKMapView *)mapView regionDidChangeAnimated
BOOL)animated {
I tried doing
This only shows the current location of the device, not the center of the map. Any help would be appreciated.
Code:
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation{
location=newLocation.coordinate;
//One location is obtained.. just zoom to that location
NSLog(@"%@",oldLocation);
if (!oldLocation) {
MKCoordinateRegion region;
region.center=location;
//Set Zoom level using Span
MKCoordinateSpan span;
span.latitudeDelta=1.5;
span.longitudeDelta=1.5;
region.span=span;
NSLog(@"center = %f",newLocation.coordinate);
[mapView setRegion:region animated:TRUE];
}
}
That returns the proper center. Unforunately, I can't figure out what to do in - (void)mapView
I tried doing
Code:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated {
NSLog(@"Scrolling");
MKCoordinateRegion region;
region.center = location;
NSLog(@"center = %f, %f",location.latitude, location.longitude);
}
This only shows the current location of the device, not the center of the map. Any help would be appreciated.