Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL
Help

Annotating Maps > Annotating Maps - Pg. 48

Feedback: 0 Comments on this Section

[viewController.tableView reloadData]; [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(animateMap:) userInfo:newLocation repeats:NO]; } - (void)animateMap: (NSTimer *)timer { CLLocation *newLocation = (CLLocation *)[timer userInfo]; double miles = 2.0; double scalingFactor = ABS( cos(2 * M_PI * newLocation.coordinate.latitude /360.0) ); MKCoordinateSpan span; span.latitudeDelta = miles/69.0; span.longitudeDelta = miles/( scalingFactor*69.0 ); MKCoordinateRegion region; region.span = span; region.center = newLocation.coordinate; [viewController.mapView setRegion:region animated:YES]; viewController.mapView.showsUserLocation = YES; } If you save your changes, and click on the Build and Run button in the Xcode toolbar again, this time you should see the map panning and zooming as we'd expect as the table view is updated by the Core Location delegate method.