RMMapRenderer.m
2.12 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
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
//
// MapRenderer.m
// RouteMe
//
// Created by Joseph Gentle on 9/09/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "RMMapRenderer.h"
#import "RMScreenProjection.h"
#import "RMFractalTileProjection.h"
#import "RMTileSource.h"
#import "RMTileImage.h"
@implementation RMMapRenderer
@synthesize screenProjection;
// Designated initialiser
- (id) initWithView: (id<RMRenderingTarget>)_view ProjectingIn: (RMScreenProjection*) _screenProjection
{
if (![super init])
return nil;
view = _view;
screenProjection = [_screenProjection retain];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mapImageLoaded:) name:RMMapImageLoadedNotification object:nil];
return self;
}
- (id) initWithView: (id<RMRenderingTarget>)_view
{
RMScreenProjection *_screenProjection = [[RMScreenProjection alloc] initWithBounds:[_view cgBounds]];
return [self initWithView:_view ProjectingIn:_screenProjection];
}
-(void) dealloc
{
[screenProjection release];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
-(void)mapImageLoaded: (NSNotification*)notification
{
[self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect
{ }
-(void) moveToMercator: (RMMercatorPoint) point
{
[screenProjection moveToMercator:point];
[self setNeedsDisplay];
}
-(void) moveToLatLong: (CLLocationCoordinate2D) point
{
[screenProjection moveToLatLong:point];
[self setNeedsDisplay];
}
- (void)moveBy: (CGSize) delta
{
[screenProjection moveBy:delta];
[view setNeedsDisplay];
}
- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center
{
[screenProjection zoomByFactor:zoomFactor Near:center];
[view setNeedsDisplay];
}
-(void) recalculateImageSet
{
}
- (void)setNeedsDisplay
{
[self recalculateImageSet];
[view setNeedsDisplay];
}
- (double) scale
{
return [screenProjection scale];
}
- (void) setScale: (double) scale
{
[screenProjection setScale:scale];
[self setNeedsDisplay];
}
//-(void)addLayer: (id<RMMapLayer>) layer above: (id<RMMapLayer>) other;
//-(void)addLayer: (id<RMMapLayer>) layer below: (id<RMMapLayer>) other;
//-(void)removeLayer: (id<RMMapLayer>) layer;
@end