-
Notifications
You must be signed in to change notification settings - Fork 0
/
CACoordLayer.m
executable file
·54 lines (44 loc) · 1.14 KB
/
CACoordLayer.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
//
// CACoordLayer.m
//
#import "CACoordLayer.h"
@implementation CACoordLayer
@dynamic mapx;
@dynamic mapy;
- (id)initWithLayer:(id)layer
{
if ((self = [super initWithLayer:layer]))
{
if ([layer isKindOfClass:[CACoordLayer class]])
{
CACoordLayer * input = layer;
self.mapx = input.mapx;
self.mapy = input.mapy;
[self setNeedsDisplay];
}
}
return self;
}
+ (BOOL)needsDisplayForKey:(NSString *)key
{
if ([@"mapx" isEqualToString:key])
{
return YES;
}
if ([@"mapy" isEqualToString:key])
{
return YES;
}
return [super needsDisplayForKey:key];
}
- (void)display
{
CACoordLayer * layer = [self presentationLayer];
BMKMapPoint mappoint = BMKMapPointMake(layer.mapx, layer.mapy);
//根据得到的坐标值,将其设置为annotation的经纬度
self.annotation.coordinate = BMKCoordinateForMapPoint(mappoint);
//设置layer的位置,显示动画
CGPoint center = [self.mapView convertCoordinate:BMKCoordinateForMapPoint(mappoint) toPointToView:self.mapView];
self.position = center;
}
@end