Created
June 16, 2014 17:31
-
-
Save Shahn-Auronas/dba8b8e009bfb209423c to your computer and use it in GitHub Desktop.
Using button within project details page to display on map
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { | |
[[tableView cellForRowAtIndexPath:indexPath] setSelected:YES]; | |
if (indexPath.section == MAP_SECTION) { | |
if ([self.locationTextField isFirstResponder]) { | |
[self.locationTextField resignFirstResponder]; | |
} | |
CLGeocoder *geocoder = [[CLGeocoder alloc] init]; | |
[geocoder geocodeAddressString:self.locationTextField.text | |
completionHandler:^(NSArray *placemarks, NSError *error) { | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
if (error) { | |
NSLog(@"Geocode failed with error: %@", error); | |
[self displayError:error]; | |
return; | |
} else if ([placemarks count] > 0){ | |
CLPlacemark *compPM = [placemarks objectAtIndex:0]; | |
MKPlacemark *placemark = [[MKPlacemark alloc] initWithPlacemark:compPM]; | |
SXAComp *compLocal = [[SXAComp alloc] init]; | |
compLocal = (SXAComp *)placemark.location; | |
MKCoordinateRegion region = self.mapView.region; | |
region.center = [(CLCircularRegion *)placemark.region center]; | |
region.span.longitudeDelta /= 8.0; | |
region.span.latitudeDelta /= 8.0; | |
[self.mapView setRegion:region animated:YES]; | |
[self.mapView addAnnotation:placemark]; | |
[self.mapView selectAnnotation:placemark animated:YES]; | |
NSLog(@"Receieved placemarks: %@", placemarks); | |
} | |
}); | |
} | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment