-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindJobsController.m
More file actions
141 lines (94 loc) · 4.3 KB
/
Copy pathFindJobsController.m
File metadata and controls
141 lines (94 loc) · 4.3 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
//
// FindJobsController.m
// Project Acorn
//
// Created by James Crowson on 28/09/2012.
// Copyright (c) 2012 James Crowson. All rights reserved.
//
#import "FindJobsController.h"
@interface FindJobsController ()
@end
@implementation FindJobsController
@synthesize listOfLatitudesOfCollectJobs;
@synthesize listOfLongitudesOfCollectJobs;
@synthesize listOfLatitudesOfDeliverJobs;
@synthesize listOfLongitudesOfDeliverJobs;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0,0,320,450)];
mapView.delegate = self;
[mapView setMapType: MKMapTypeStandard];
[self.view addSubview: mapView];
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
[locationManager setDistanceFilter:kCLDistanceFilterNone];
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[mapView setShowsUserLocation:YES];
[mapView setUserTrackingMode:MKUserTrackingModeFollowWithHeading animated:YES];
self.listOfLatitudesOfCollectJobs = [[NSArray alloc] initWithObjects:@"51.488936",@"51.517017",nil];
self.listOfLongitudesOfCollectJobs = [[NSArray alloc] initWithObjects:@"-0.1221",@"-0.123611",nil];
self.listOfLatitudesOfDeliverJobs = [[NSArray alloc] initWithObjects:@"51.490229",@"51.517717",nil];
self.listOfLongitudesOfDeliverJobs = [[NSArray alloc] initWithObjects:@"-0.119137",@"-0.126898",nil];
for (int i=0; i<2; i++) {
CLLocationCoordinate2D coordinate;
coordinate.latitude = [[self.listOfLatitudesOfCollectJobs objectAtIndex:i] doubleValue];
coordinate.longitude = [[self.listOfLongitudesOfCollectJobs objectAtIndex:i] doubleValue];;
MKPointAnnotation *annotation = [[MKPointAnnotation alloc]init];
[annotation setCoordinate:coordinate];
[annotation setTitle:[NSString stringWithFormat:@"%i", i]];
[mapView addAnnotation:annotation];
}
}
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view {
MKPointAnnotation *annotation = view.annotation;
NSString *annotationID = view.annotation.title;
if([annotation.title isEqualToString:annotationID])
{
CLLocationCoordinate2D coordinate;
coordinate.latitude = [[self.listOfLatitudesOfDeliverJobs objectAtIndex:[annotationID intValue]] doubleValue];
coordinate.longitude = [[self.listOfLongitudesOfDeliverJobs objectAtIndex:[annotationID intValue]] doubleValue];;
MKPointAnnotation *annotation = [[MKPointAnnotation alloc]init];
[annotation setCoordinate:coordinate];
[annotation setTitle:[NSString stringWithFormat:@"Deliver"]];
[mapView addAnnotation:annotation];
}
}
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
if ([[annotation title] isEqualToString:@"Deliver"] ) {
NSLog(@"Selected Deliver");
static NSString *annotationIdentifier = @"DeliveryPinIdentifier";
MKPinAnnotationView *deliverPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
[deliverPin setPinColor:MKPinAnnotationColorGreen];
deliverPin.animatesDrop = NO;
deliverPin.canShowCallout = YES;
return deliverPin;
}
/*
static NSString *annotationIdentifier = @"CollectPinIdentifier";
MKPinAnnotationView *collectPin = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
[collectPin setPinColor:MKPinAnnotationColorRed];
collectPin.animatesDrop = YES;
collectPin.canShowCallout = YES;
return collectPin;
*/
return nil;
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end