-
Notifications
You must be signed in to change notification settings - Fork 0
/
LocationMapView.m
116 lines (71 loc) · 3.15 KB
/
LocationMapView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// LocationMapView.m
// FlashAdd
//
// Created by Ray Wu on 5/13/12.
// Copyright (c) 2012 Weill Cornell. All rights reserved.
//
#import "LocationMapView.h"
@implementation LocationMapView
@synthesize coordinate, locationAdded, amigo;
- (IBAction)closeMap:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (id)initWithLocation:(CLLocation *)loc
{
self = [super init];
if (self){
/*CLLocationCoordinate2D coord = [loc coordinate];
//[worldView setCenterCoordinate:coord];
//create an instance of BNRMapPoint with the current data
BNRMapPoint *mp = [[BNRMapPoint alloc] initWithCoordinate:coord title:@"Location Created"];
//add it to the map view
[worldView addAnnotation:mp];
//zoom the region to this location
// CLLocationCoordinate2D coord;
//coord.latitude = 34;
//coord.longitude = 118;
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(coord, 200, 200);
[worldView setRegion:region animated:YES];
}*/}
return self;
}
- (void)viewWillAppear:(BOOL)animated
{
CLLocationCoordinate2D zoomLocation = [[amigo locationCreated] coordinate];
BNRMapPoint *mp = [[BNRMapPoint alloc] initWithCoordinate:zoomLocation title:[NSString stringWithFormat:@"%@ %@", [amigo firstName], [amigo lastName]]];
//add it to the map view
NSDateFormatter *dayFormatter = [[NSDateFormatter alloc] init];
[dayFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dayFormatter setDateStyle:NSDateFormatterMediumStyle];
NSString *dayString = [[NSString alloc] initWithFormat:@"%@", [dayFormatter stringFromDate:[amigo dateCreated]]];
[mp setSubtitle:dayString];
//[worldView addAnnotation:mp];
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 200, 200);
// 3
[worldView setRegion:viewRegion animated:YES];
//[NameLabel setText:[NSString stringWithFormat:@"Location %@ %@ added to contacts", [amigo firstName], [amigo lastName]]];
}
- (void)viewDidUnload {
NameLabel = nil;
[super viewDidUnload];
}
- (void)viewDidLoad{
worldView.delegate = self;
}
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
static NSString * AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView* pinView = [[MKPinAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
//pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
UIButton *rightbutton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
//[rightbutton setCoor
[rightbutton setTitle:annotation.title forState:UIControlStateNormal];
[rightbutton addTarget:self action:nil forControlEvents:UIControlEventTouchUpInside];
pinView.rightCalloutAccessoryView = rightbutton;
UIImageView *ContactThumbnail = [[UIImageView alloc]initWithImage:[amigo thumbnail]];
pinView.leftCalloutAccessoryView = ContactThumbnail;
return pinView;
}
@end