-
Notifications
You must be signed in to change notification settings - Fork 0
/
MapViewController.m
executable file
·606 lines (499 loc) · 20.5 KB
/
MapViewController.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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
/** CycleTracks, Copyright 2009-2013 San Francisco County Transportation Authority
* San Francisco, CA, USA
*
* @author Matt Paul <mattpaul@mopimp.com>
*
* This file is part of CycleTracks.
*
* CycleTracks is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CycleTracks is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CycleTracks. If not, see <http://www.gnu.org/licenses/>.
*/
//
// MapViewController.m
// CycleTracks
//
// Copyright 2009-2013 SFCTA. All rights reserved.
// Written by Matt Paul <mattpaul@mopimp.com> on 9/28/09.
// For more information on the project,
// e-mail Elizabeth Sall at the SFCTA <elizabeth.sall@sfcta.org>
#import "Coord.h"
#import "LoadingView.h"
#import "MapCoord.h"
#import "MapViewController.h"
#import "Trip.h"
#import "TripQuestionsViewController.h"
#import "TripPurposeDelegate.h"
#import "SavedTripsViewController.h"
#import "FloridaTripTrackerAppDelegate.h"
#import "constants.h"
#define kFudgeFactor 1.5
#define kInfoViewAlpha 0.8
#define kMinLatDelta 0.0039
#define kMinLonDelta 0.0034
@implementation MapViewController
@synthesize doneButton, flipButton, infoView, trip;
@synthesize viewTrips,addDetailInfo,removeTrip,tripInfo;//lx 0401
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
*/
- (id)initWithTrip:(Trip *)_trip
{
//if (self = [super init]) {
if (self = [super initWithNibName:@"MapViewController" bundle:nil]) {
NSLog(@"MapViewController initWithTrip");
self.trip = _trip;
mapView.delegate = self;
}
return self;
}
//[LIU] new added button for link to detailed info
- (IBAction)addDetailInfo:(id)sender {
//TripQuestionsViewController *pickerViewController = [[TripQuestionsViewController alloc]
// initWithNibName:@"TripPurposePicker" bundle:nil];
TripQuestionsViewController *pickerViewController = [[TripQuestionsViewController alloc] initWithTrip:self.trip];
SavedTripsViewController *savedTripsViewController = [[SavedTripsViewController alloc]init];
TripManager *manager = [[TripManager alloc] init];
[savedTripsViewController initTripManager:manager];
[pickerViewController setDelegate:savedTripsViewController];
[self.navigationController presentViewController:pickerViewController animated:YES completion:nil];
/*TripQuestionsViewController *pickerViewController = [[TripQuestionsViewController alloc]
initWithNibName:@"TripPurposePicker" bundle:nil];
[pickerViewController setDelegate:self];
[self.navigationController presentViewController:pickerViewController animated:YES completion:nil];*/
}
//[LIU]
- (NSString *)updatePurposeWithString:(NSString *)purpose
{
// update UI
/*
if ( tripPurposeCell != nil )
{
tripPurposeCell.accessoryType = UITableViewCellAccessoryCheckmark;
tripPurposeCell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"GreenCheckMark3.png"]];
tripPurposeCell.detailTextLabel.text = purpose;
tripPurposeCell.detailTextLabel.enabled = YES;
tripPurposeCell.detailTextLabel.adjustsFontSizeToFitWidth = YES;
tripPurposeCell.detailTextLabel.minimumFontSize = kMinimumFontSize;
}
*/
// only enable start button if we don't already have a pending trip
return purpose;
}
- (void)initTripManager:(TripManager*)manager
{
//manager.activityDelegate = self;
//manager.alertDelegate = self;
//manager.dirty = YES;
//self.tripManager = manager;
}
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == [alertView firstOtherButtonIndex]){
[self deleteTrip];
}else{
}
}
- (void) deleteTrip{
NSNumber *tripID = self.trip.sysTripID;
NSData *postData = [tripID.description dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%ld", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
[request setURL:[NSURL URLWithString:KRemoveTripById]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSDictionary *serverFeedback = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];
NSString *serverFeedbackString = [serverFeedback objectForKey:@"Result"];
if ([serverFeedbackString hasSuffix:@"successfully."]) {
FloridaTripTrackerAppDelegate *delegate= [[UIApplication sharedApplication] delegate];
NSManagedObjectContext *managedContext= [delegate managedObjectContext];
[managedContext deleteObject:self.trip];
// Commit the change.
NSError *error;
if (![managedContext save:&error]) {
// Handle the error.
NSLog(@"Delete Trip FAILED.................%@", [error localizedDescription]);
}
}
[self.navigationController popViewControllerAnimated:YES];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirmation"
message:@"The trip has been deleted on server and removed from local database."
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
//lx 0401
- (IBAction)viewtrips:(id)sender {
FloridaTripTrackerAppDelegate *delegate= [[UIApplication sharedApplication] delegate];
[self.navigationController popViewControllerAnimated:YES];
}
//[LIU]Remove trip
- (IBAction)removeTrip:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Delete Trip"
message:@"Do you confirm this is an incorrect trip generated by model?"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"Yes", @"Cancel", nil];
[alert show];
// NSNumber *tripID = self.trip.sysTripID;
// NSData *postData = [tripID.description dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
// NSString *postLength = [NSString stringWithFormat:@"%ld", [postData length]];
// NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
// [request setURL:[NSURL URLWithString:KRemoveTripById]];
//
// [request setHTTPMethod:@"POST"];
// [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
// [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
// [request setHTTPBody:postData];
//
// NSURLResponse *response;
// NSError *err;
//
// NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
// NSDictionary *serverFeedback = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:nil];
// NSString *serverFeedbackString = [serverFeedback objectForKey:@"Result"];
//
// if ([serverFeedbackString hasSuffix:@"successfully."]) {
// FloridaTripTrackerAppDelegate *delegate= [[UIApplication sharedApplication] delegate];
// NSManagedObjectContext *managedContext= [delegate managedObjectContext];
// [managedContext deleteObject:self.trip];
// // Commit the change.
// NSError *error;
// if (![managedContext save:&error]) {
// // Handle the error.
// NSLog(@"Delete Trip FAILED.................%@", [error localizedDescription]);
// }
// }
//
// [self.navigationController popViewControllerAnimated:YES];
}
- (void)infoAction:(UIButton*)sender
{
NSLog(@"infoAction");
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:animationIDfinished:finished:context:)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:([infoView superview] ?
UIViewAnimationTransitionFlipFromLeft : UIViewAnimationTransitionFlipFromRight)
forView:self.view cache:YES];
if ([infoView superview])
[infoView removeFromSuperview];
else
[self.view addSubview:infoView];
[UIView commitAnimations];
// adjust our done/info buttons accordingly
if ([infoView superview] == self.view)
self.navigationItem.rightBarButtonItem = doneButton;
else
self.navigationItem.rightBarButtonItem = flipButton;
}
- (void)initInfoView
{
infoView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,460)];
infoView.alpha = kInfoViewAlpha;
infoView.backgroundColor = [UIColor blackColor];
UILabel *notesHeader = [[UILabel alloc] initWithFrame:CGRectMake(9,85,160,25)];
notesHeader.backgroundColor = [UIColor clearColor];
notesHeader.font = [UIFont boldSystemFontOfSize:18.0];
notesHeader.opaque = NO;
notesHeader.text = @"Trip Notes";
notesHeader.textColor = [UIColor whiteColor];
[infoView addSubview:notesHeader];
UITextView *notesText = [[UITextView alloc] initWithFrame:CGRectMake(0,110,320,200)];
notesText.backgroundColor = [UIColor clearColor];
notesText.editable = NO;
notesText.font = [UIFont systemFontOfSize:16.0];
notesText.text = @"";
notesText.textColor = [UIColor whiteColor];
[infoView addSubview:notesText];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
UIBarButtonItem * item = [[UIBarButtonItem alloc] initWithCustomView:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"FDOT"]]];
self.navigationItem.rightBarButtonItem = item;
if ( trip )
{
// format date as a string
static NSDateFormatter *dateFormatter = nil;
if (dateFormatter == nil) {
dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
}
// display duration, distance as navbar prompt
static NSDateFormatter *inputFormatter = nil;
if ( inputFormatter == nil )
inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"HH:mm:ss"];
NSDate *fauxDate = [inputFormatter dateFromString:@"00:00:00"];
[inputFormatter setDateFormat:@"HH:mm:ss"];
//self.title = trip.purpose;
// filter coords by hAccuracy
NSPredicate *filterByAccuracy = [NSPredicate predicateWithFormat:@"hAccuracy < 100.0"];
NSArray *filteredCoords = [[trip.coords allObjects] filteredArrayUsingPredicate:filterByAccuracy];
//[LIU]how many records in the selected trip
NSArray *coordsAmount = [trip.coords allObjects];
int a = [coordsAmount count];
//NSLog(@"%d...................how many coords for one trip...................", a);
if(a>0)
{
// sort filtered coords by recorded date
NSSortDescriptor *sortByDate = [[NSSortDescriptor alloc] initWithKey:@"recorded" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sortByDate, nil];
NSArray *sortedCoords = [filteredCoords sortedArrayUsingDescriptors:sortDescriptors];
// add coords as annotations to map
BOOL first = YES;
Coord *last = nil;
MapCoord *pin = nil;
int count = 0;
// calculate min/max values for lat, lon
NSNumber *minLat = [NSNumber numberWithDouble:0.0];
NSNumber *maxLat = [NSNumber numberWithDouble:0.0];
NSNumber *minLon = [NSNumber numberWithDouble:0.0];
NSNumber *maxLon = [NSNumber numberWithDouble:0.0];
// [LIU] show average speed in mapView
Coord *firstCoord = [sortedCoords objectAtIndex:0];
Coord *lastCoord = [sortedCoords lastObject];
NSTimeInterval duration = [lastCoord.recorded timeIntervalSinceDate:firstCoord.recorded];
NSLog(@"duration = %.0fs", duration);
[trip setDuration:[NSNumber numberWithDouble:duration]];
double mph = ( [trip.distance doubleValue] / 1609.344 ) / ( [trip.duration doubleValue] / 3600. );
NSDate *outputDate = [[NSDate alloc] initWithTimeInterval:(NSTimeInterval)[trip.duration doubleValue]
sinceDate:fauxDate];
//[LIU0406]
// self.navigationItem.prompt = [NSString stringWithFormat:@"elapsed: %@ ~ %@",
// [inputFormatter stringFromDate:outputDate],
// [dateFormatter stringFromDate:[trip startTime]]];
// self.title = [NSString stringWithFormat:@"%.1f mi ~ %.1f mph elapsed: %@ ~ %@",
// [trip.distance doubleValue] / 1609.344, mph, [inputFormatter stringFromDate:outputDate],
// [dateFormatter stringFromDate:[trip startTime]] ];
// self.title = [NSString stringWithFormat:@"%.1f mi ~ %.1f mph",
// [trip.distance doubleValue] / 1609.344, mph];
//[LIU0406]
self.title = [NSString stringWithFormat:@"MyTripDiary"];
tripInfo.lineBreakMode = NSLineBreakByWordWrapping;
tripInfo.numberOfLines = 0;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM/dd/yyyy, hh:mm:ss a"];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[dateFormat setLocale:locale];
//startTime && stopTime
NSString *startTime=[dateFormat stringFromDate:trip.startTime];
NSString *stopTime=[dateFormat stringFromDate:trip.stopTime];
if( trip.purpose.length > 0){
self.tripInfo.text = [NSString stringWithFormat:@"Start Time: %@ \nEnd Time: %@\nPurpose: %@", startTime, stopTime, trip.purpose];}
else{
self.tripInfo.text = [NSString stringWithFormat:@"Start Time: %@ \nEnd Time: %@", startTime, stopTime];
}
for ( Coord *coord in sortedCoords )
{
// only plot unique coordinates to our map for performance reasons
if ( !last ||
(![coord.latitude isEqualToNumber:last.latitude] &&
![coord.longitude isEqualToNumber:last.longitude] ) )
{
CLLocationCoordinate2D coordinate;
coordinate.latitude = [coord.latitude doubleValue];
coordinate.longitude = [coord.longitude doubleValue];
pin = [[MapCoord alloc] init];
pin.coordinate = coordinate;
if ( first )
{
// add start point as a pin annotation
first = NO;
pin.first = YES;
pin.title = @"Start";
pin.subtitle = [dateFormatter stringFromDate:coord.recorded];
//[mapView selectAnnotation:pin animated:YES];
//NSLog(@"%@ ......first recorded time......", coord);
// initialize min/max values to the first coord
minLat = coord.latitude;
maxLat = coord.latitude;
minLon = coord.longitude;
maxLon = coord.longitude;
}
else
{
// update min/max values
if ( [minLat compare:coord.latitude] == NSOrderedDescending )
minLat = coord.latitude;
if ( [maxLat compare:coord.latitude] == NSOrderedAscending )
maxLat = coord.latitude;
if ( [minLon compare:coord.longitude] == NSOrderedDescending )
minLon = coord.longitude;
if ( [maxLon compare:coord.longitude] == NSOrderedAscending )
maxLon = coord.longitude;
}
[mapView addAnnotation:pin];
count++;
}
// update last coord pointer so we can cull redundant coords above
last = coord;
}
// add end point as a pin annotation
if ( (last = [sortedCoords lastObject]) )
{
pin.last = YES;
pin.title = @"End";
pin.subtitle = [dateFormatter stringFromDate:last.recorded];
//[mapView selectAnnotation:pin animated:YES];
}
// if we had at least 1 coord
if ( count )
{
// add a small fudge factor to ensure
// North-most pins are visible
double latDelta = kFudgeFactor * ( [maxLat doubleValue] - [minLat doubleValue] );
if ( latDelta < kMinLatDelta )
latDelta = kMinLatDelta;
double lonDelta = [maxLon doubleValue] - [minLon doubleValue];
if ( lonDelta < kMinLonDelta )
lonDelta = kMinLonDelta;
MKCoordinateRegion region = { { [minLat doubleValue] + latDelta / 2,
[minLon doubleValue] + lonDelta / 2 },
{ latDelta,
lonDelta } };
[mapView setRegion:region animated:NO];
}
else
{
// init map region to San Francisco
MKCoordinateRegion region = { { 37.7620, -122.4350 }, { 0.10825, 0.10825 } };
[mapView setRegion:region animated:NO];
}
}
}
else
{
// error: init map region to San Francisco
MKCoordinateRegion region = { { 37.7620, -122.4350 }, { 0.10825, 0.10825 } };
[mapView setRegion:region animated:NO];
}
LoadingView *loading = (LoadingView*)[self.parentViewController.view viewWithTag:909];
//NSLog(@"loading: %@", loading);
[loading performSelector:@selector(removeView) withObject:nil afterDelay:0.5];
}
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
#pragma mark MKMapViewDelegate methods
- (void)mapViewWillStartLoadingMap:(MKMapView *)mapView
{
//NSLog(@"mapViewWillStartLoadingMap");
}
- (void)mapViewDidFailLoadingMap:(MKMapView *)mapView withError:(NSError *)error
{
NSLog(@"mapViewDidFailLoadingMap:withError: %@", [error localizedDescription]);
}
- (void)mapViewDidFinishLoadingMap:(MKMapView *)_mapView
{
//NSLog(@"mapViewDidFinishLoadingMap");
LoadingView *loading = (LoadingView*)[self.parentViewController.view viewWithTag:909];
//NSLog(@"loading: %@", loading);
[loading removeView];
}
- (MKAnnotationView *)mapView:(MKMapView *)_mapView
viewForAnnotation:(id <MKAnnotation>)annotation
{
//NSLog(@"viewForAnnotation");
// If it's the user location, just return nil.
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
// Handle any custom annotations.
if ([annotation isKindOfClass:[MapCoord class]])
{
MKAnnotationView* annotationView = nil;
if ( [(MapCoord*)annotation first] )
{
// Try to dequeue an existing pin view first.
//MKPinAnnotationView* pinView = (MKPinAnnotationView*)[mapView
// dequeueReusableAnnotationViewWithIdentifier:@"FirstCoord"];
MKAnnotationView* pinView = (MKPinAnnotationView*)[mapView
dequeueReusableAnnotationViewWithIdentifier:@"FirstCoord"];
if ( !pinView )
{
// If an existing pin view was not available, create one
//pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"FirstCoord"];
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"FirstCoord"];
//pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
//pinView.pinColor = MKPinAnnotationColorGreen;
pinView.image = [UIImage imageNamed:@"PinGreen.png"];
}
annotationView = pinView;
}
else if ( [(MapCoord*)annotation last] )
{
// Try to dequeue an existing pin view first.
//MKPinAnnotationView* pinView = (MKPinAnnotationView*)[mapView
// dequeueReusableAnnotationViewWithIdentifier:@"LastCoord"];
MKAnnotationView* pinView = (MKPinAnnotationView*)[mapView
dequeueReusableAnnotationViewWithIdentifier:@"LastCoord"];
if ( !pinView )
{
// If an existing pin view was not available, create one
//pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"LastCoord"];
pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"LastCoord"];
//pinView.animatesDrop = YES;
pinView.canShowCallout = YES;
//pinView.pinColor = MKPinAnnotationColorRed;
pinView.image = [UIImage imageNamed:@"PinRed.png"];
}
annotationView = pinView;
}
else
{
// Try to dequeue an existing pin view first.
annotationView = (MKAnnotationView*)[mapView
dequeueReusableAnnotationViewWithIdentifier:@"MapCoord"];
if (!annotationView)
{
// If an existing pin view was not available, create one
annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MapCoord"];
annotationView.image = [UIImage imageNamed:@"MapCoord.png"];
}
}
return annotationView;
}
return nil;
}
@end