Advertisement
Joze

Using Maps on iOS

Dec 28th, 2011
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Don't forget to include #import <MapKit/MapKit.h> and MapKit.framework
  2.  
  3. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath
  4. {
  5.     MKMapView *mapa = (MKMapView *) [cell viewWithTag:TAG_CELL_MAP];
  6.    
  7.     NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];
  8.    
  9.     double latitude = [[managedObject valueForKey:@"photo_latitude"] doubleValue];
  10.     double longitude = [[managedObject valueForKey:@"photo_longitude"] doubleValue];
  11.     CLLocationCoordinate2D location = CLLocationCoordinate2DMake(latitude, longitude);
  12.  
  13.     MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(location,MAP_ZOOM_DISTANCE_X,MAP_ZOOM_DISTANCE_Y);    
  14.     [mapa setRegion:region animated:NO];
  15.    
  16.     MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init];
  17.     annotationPoint.coordinate = location;
  18.     annotationPoint.title = @"Pic";
  19.     annotationPoint.subtitle = @"Naino naaaai";
  20.     [mapa addAnnotation:annotationPoint];
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement