RMMapLayer.m
1 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
//
// Layer.m
// MapView
//
// Created by Joseph Gentle on 22/09/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "RMMapLayer.h"
#import "RMPixel.h"
@implementation RMMapLayer
- (id) init
{
if (![super init])
return nil;
return self;
}
- (id)initWithLayer:(id)layer
{
if (![super initWithLayer:layer])
return nil;
return self;
}
- (id<CAAction>)actionForKey:(NSString *)key
{
if ([key isEqualToString:@"position"]
|| [key isEqualToString:@"bounds"])
return nil;
else return [super actionForKey:key];
}
- (void)moveBy: (CGSize) delta
{
self.position = RMTranslateCGPointBy(self.position, delta);
}
- (void)zoomByFactor: (float) zoomFactor near:(CGPoint) center
{
CGRect currentRect = CGRectMake(self.position.x, self.position.y, self.bounds.size.width, self.bounds.size.height);
CGRect newRect = RMScaleCGRectAboutPoint(currentRect, zoomFactor, center);
self.position = newRect.origin;
self.bounds = CGRectMake(0, 0, newRect.size.width, newRect.size.height);
}
@end