|
|
@@ -29,7 +29,7 @@
|
|
|
|
|
|
#import <AddressBook/AddressBook.h>
|
|
|
//#import <Contacts/Contacts.h>
|
|
|
-#import "RADetailMapCell.h"
|
|
|
+
|
|
|
#import "RADetailPhotoModel.h"
|
|
|
#import "RADetailMapModel.h"
|
|
|
|
|
|
@@ -78,6 +78,7 @@
|
|
|
RADetailMapCell *cell = [tableView dequeueReusableCellWithIdentifier:@"RADetailMapCell" forIndexPath:indexPath];
|
|
|
RADetailMapModel *mapModel = (RADetailMapModel *)model;
|
|
|
[cell setModel:mapModel];
|
|
|
+ cell.delegate = self;
|
|
|
return cell;
|
|
|
}
|
|
|
break;
|
|
|
@@ -114,6 +115,34 @@
|
|
|
return [self sectionNumber];
|
|
|
}
|
|
|
|
|
|
+#pragma mark - Map
|
|
|
+
|
|
|
+- (void)openMapWithTitle:(NSString *)title model:(RADetailMapModel *)model {
|
|
|
+
|
|
|
+ if (model == nil) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([model.lat doubleValue], [model.lon doubleValue]);
|
|
|
+
|
|
|
+ MKMapItem *toLocation = [[MKMapItem alloc] initWithPlacemark:[[MKPlacemark alloc] initWithCoordinate:coordinate
|
|
|
+ addressDictionary:nil]];
|
|
|
+ toLocation.name = title;
|
|
|
+ [MKMapItem openMapsWithItems:@[toLocation] launchOptions:@{
|
|
|
+ MKLaunchOptionsMapCenterKey : [NSValue valueWithMKCoordinate:coordinate]
|
|
|
+ }];
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)mapCell:(RADetailMapCell *)cell clickMapButtonWithModel:(RADetailMapModel *)model {
|
|
|
+
|
|
|
+ NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
|
|
|
+
|
|
|
+ NSString *title = [self titleForSection:indexPath.section];
|
|
|
+
|
|
|
+ [self openMapWithTitle:title model:model];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Photo/Signature
|
|
|
|
|
|
- (void)previewImage:(UIImage *)img {
|