-
Notifications
You must be signed in to change notification settings - Fork 262
/
ARKitDemoAppDelegate.m
284 lines (172 loc) · 8.42 KB
/
ARKitDemoAppDelegate.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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
//
// ARKitDemoAppDelegate.m
// ARKitDemo
//
// Created by Zac White on 8/1/09.
// Copyright Zac White 2009. All rights reserved.
//
#import "ARKitDemoAppDelegate.h"
#import "ARGeoCoordinate.h"
#import <MapKit/MapKit.h>
@implementation ARKitDemoAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
ARGeoViewController *viewController = [[ARGeoViewController alloc] init];
viewController.debugMode = YES;
viewController.delegate = self;
viewController.scaleViewsBasedOnDistance = YES;
viewController.minimumScaleFactor = .5;
viewController.rotateViewsBasedOnPerspective = YES;
NSMutableArray *tempLocationArray = [[NSMutableArray alloc] initWithCapacity:10];
CLLocation *tempLocation;
ARGeoCoordinate *tempCoordinate;
CLLocationCoordinate2D location;
location.latitude = 39.550051;
location.longitude = -105.782067;
tempLocation = [[CLLocation alloc] initWithCoordinate:location altitude:1609.0 horizontalAccuracy:1.0 verticalAccuracy:1.0 timestamp:[NSDate date]];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Denver";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:45.523875 longitude:-122.670399];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Portland";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:41.879535 longitude:-87.624333];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Chicago";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:30.268735 longitude:-97.745209];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Austin";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:51.500152 longitude:-0.126236];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/30;
tempCoordinate.title = @"London";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:48.856667 longitude:2.350987];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/30;
tempCoordinate.title = @"Paris";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:47.620973 longitude:-122.347276];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Seattle";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:20.593684 longitude:78.96288];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/32;
tempCoordinate.title = @"India";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:55.676294 longitude:12.568116];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/30;
tempCoordinate.title = @"Copenhagen";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:52.373801 longitude:4.890935];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/30;
tempCoordinate.title = @"Amsterdam";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:19.611544 longitude:-155.665283];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/30;
tempCoordinate.title = @"Hawaii";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:-40.900557 longitude:174.885971];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/40;
tempCoordinate.title = @"New Zealand";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:40.756054 longitude:-73.986951];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"New York City";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:42.35892 longitude:-71.05781];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Boston";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:49.817492 longitude:15.472962];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/30;
tempCoordinate.title = @"Czech Republic";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:53.41291 longitude:-8.24389];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.inclination = M_PI/30;
tempCoordinate.title = @"Ireland";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:45.545447 longitude:-73.639076];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Montreal";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:38.892091 longitude:-77.024055];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Washington, DC";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:-40.900557 longitude:174.885971];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Munich";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
tempLocation = [[CLLocation alloc] initWithLatitude:32.781078 longitude:-96.797111];
tempCoordinate = [ARGeoCoordinate coordinateWithLocation:tempLocation];
tempCoordinate.title = @"Dallas";
[tempLocationArray addObject:tempCoordinate];
[tempLocation release];
[viewController addCoordinates:tempLocationArray];
[tempLocationArray release];
CLLocation *newCenter = [[CLLocation alloc] initWithLatitude:37.41711 longitude:-122.02528];
viewController.centerLocation = newCenter;
[newCenter release];
[viewController startListening];
[window addSubview:viewController.view];
// Override point for customization after application launch
[window makeKeyAndVisible];
}
#define BOX_WIDTH 150
#define BOX_HEIGHT 100
- (UIView *)viewForCoordinate:(ARCoordinate *)coordinate {
CGRect theFrame = CGRectMake(0, 0, BOX_WIDTH, BOX_HEIGHT);
UIView *tempView = [[UIView alloc] initWithFrame:theFrame];
//tempView.backgroundColor = [UIColor colorWithWhite:.5 alpha:.3];
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, BOX_WIDTH, 20.0)];
titleLabel.backgroundColor = [UIColor colorWithWhite:.3 alpha:.8];
titleLabel.textColor = [UIColor whiteColor];
titleLabel.textAlignment = UITextAlignmentCenter;
titleLabel.text = coordinate.title;
[titleLabel sizeToFit];
titleLabel.frame = CGRectMake(BOX_WIDTH / 2.0 - titleLabel.frame.size.width / 2.0 - 4.0, 0, titleLabel.frame.size.width + 8.0, titleLabel.frame.size.height + 8.0);
UIImageView *pointView = [[UIImageView alloc] initWithFrame:CGRectZero];
pointView.image = [UIImage imageNamed:@"location.png"];
pointView.frame = CGRectMake((int)(BOX_WIDTH / 2.0 - pointView.image.size.width / 2.0), (int)(BOX_HEIGHT / 2.0 - pointView.image.size.height / 2.0), pointView.image.size.width, pointView.image.size.height);
[tempView addSubview:titleLabel];
[tempView addSubview:pointView];
[titleLabel release];
[pointView release];
return [tempView autorelease];
}
- (void)dealloc {
//NEW COMMENT!
[window release];
[super dealloc];
}
@end