-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapLinesAnnotation.m
More file actions
58 lines (43 loc) · 1.39 KB
/
Copy pathMapLinesAnnotation.m
File metadata and controls
58 lines (43 loc) · 1.39 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
//
// MapLinesAnnotation.m
// Sleep Blaster touch
//
// Created by Eamon Ford on 4/10/10.
// Copyright 2010 The Byte Factory. All rights reserved.
//
#import "MapLinesAnnotation.h"
@implementation MapLinesAnnotation
@synthesize points;
@synthesize coordinate = center;
@synthesize span;
- (id)initWithPoints:(NSArray *)thePoints
{
self = [super init];
points = [thePoints mutableCopy];
// determine a logical center point for this route based on the middle of the lat/lon extents.
double maxLat = -91;
double minLat = 91;
double maxLon = -181;
double minLon = 181;
for(CLLocation* currentLocation in points)
{
CLLocationCoordinate2D coordinate = currentLocation.coordinate;
if(coordinate.latitude > maxLat)
maxLat = coordinate.latitude;
if(coordinate.latitude < minLat)
minLat = coordinate.latitude;
if(coordinate.longitude > maxLon)
maxLon = coordinate.longitude;
if(coordinate.longitude < minLon)
minLon = coordinate.longitude;
}
span.latitudeDelta = (maxLat + 90) - (minLat + 90);
span.longitudeDelta = (maxLon + 180) - (minLon + 180);
// the center point is the average of the max and mins
center.latitude = minLat + span.latitudeDelta / 2;
center.longitude = minLon + span.longitudeDelta / 2;
// self.lineColor = [UIColor blueColor];
NSLog(@"Found center of new Route Annotation at %lf, %lf", center.latitude, center.longitude);
return self;
}
@end