Skip to content

Instantly share code, notes, and snippets.

@jerryhjones
Created October 18, 2013 01:33
Show Gist options
  • Save jerryhjones/7035129 to your computer and use it in GitHub Desktop.
Save jerryhjones/7035129 to your computer and use it in GitHub Desktop.
-(void)configureWithVenue:(Venue *)venue
{
self.venueName = venue.name;
self.addressLabel.text = [venue.address fullAddressWithMultipleLines:YES includeCountry:NO];
dispatch_async(dispatch_get_main_queue(), ^{
if(nil == self.mapView) {
MKMapView *mapView = [[MKMapView alloc] initWithFrame:self.mapViewContainer.bounds];
self.mapView = mapView;
[self.mapViewContainer addSubview:mapView];
}
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([venue.latitude doubleValue], [venue.longitude doubleValue]);
MKCoordinateRegion region;
region.center = coordinate;
region.span = MKCoordinateSpanMake(1.0f/69.0f, 1.0f/69.0f);
[self.mapView setRegion:region];
//Offset map's center
CLLocationCoordinate2D center = coordinate;
center.latitude -= (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? 1.0f / 700.0f : 1.0f / -700.0f;
center.longitude -= 1.0f / 130.0f;
[self.mapView setCenterCoordinate:center];
self.mapView.userInteractionEnabled = NO;
GSAnnotation *annotaton = [venue mapAnnotation];
if (annotaton) {
[self.mapView addAnnotation:annotaton];
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment