Partially implemented map layers.
Fixed the bug producing seams between tiles.
Showing
10 changed files
with
149 additions
and
27 deletions
@@ -8,18 +8,23 @@ | @@ -8,18 +8,23 @@ | ||
8 | 8 | ||
9 | #import <Foundation/Foundation.h> | 9 | #import <Foundation/Foundation.h> |
10 | #import <QuartzCore/QuartzCore.h> | 10 | #import <QuartzCore/QuartzCore.h> |
11 | +#import "RMMercator.h" | ||
12 | +#import "RMMapLayer.h" | ||
11 | 13 | ||
12 | -@protocol RMMapLayer; | 14 | +@class RMMapRenderer; |
13 | 15 | ||
14 | @interface RMLayerSet : NSObject | 16 | @interface RMLayerSet : NSObject |
15 | { | 17 | { |
16 | NSMutableArray *layers; | 18 | NSMutableArray *layers; |
19 | + | ||
20 | + CALayer *container; | ||
17 | } | 21 | } |
18 | 22 | ||
19 | -- (void)addAbove: (id)layer; | ||
20 | -- (void)addBelow: (id)layer; | ||
21 | - | 23 | +- (void)insertSublayer:(RMMapLayer*) layer below:(RMMapLayer*)sibling; |
24 | +- (void)insertSublayer:(RMMapLayer*) layer above:(RMMapLayer*)sibling; | ||
25 | +- (void)removeSublayer:(RMMapLayer*) layer; | ||
22 | 26 | ||
27 | +- (void)moveToMercator: (RMMercatorPoint)mercator; | ||
23 | - (void)moveBy: (CGSize) delta; | 28 | - (void)moveBy: (CGSize) delta; |
24 | - (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center; | 29 | - (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center; |
25 | 30 |
@@ -11,4 +11,50 @@ | @@ -11,4 +11,50 @@ | ||
11 | 11 | ||
12 | @implementation RMLayerSet | 12 | @implementation RMLayerSet |
13 | 13 | ||
14 | +- (id) init | ||
15 | +{ | ||
16 | + if (![super init]) | ||
17 | + return nil; | ||
18 | + | ||
19 | + container = [[CALayer alloc] init]; | ||
20 | + | ||
21 | + | ||
22 | + return self; | ||
23 | +} | ||
24 | + | ||
25 | +/* | ||
26 | +- (void)insertSublayer:(RMMapLayer*) layer below:(RMMapLayer*)sibling; | ||
27 | +- (void)insertSublayer:(RMMapLayer*) layer above:(RMMapLayer*)sibling; | ||
28 | +- (void)removeSublayer:(RMMapLayer*) layer; | ||
29 | + | ||
30 | +- (void)moveToMercator: (RMMercatorPoint)mercator; | ||
31 | +*/ | ||
32 | +- (void)moveBy: (CGSize) delta | ||
33 | +{ | ||
34 | + for (id layer in layers) | ||
35 | + { | ||
36 | + if ([layer respondsToSelector:@selector(moveBy:)]) | ||
37 | + [layer moveBy:delta]; | ||
38 | + } | ||
39 | +} | ||
40 | + | ||
41 | +- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center | ||
42 | +{ | ||
43 | + for (id layer in layers) | ||
44 | + { | ||
45 | + if ([layer respondsToSelector:@selector(zoomByFactor:Near:)]) | ||
46 | + [layer zoomByFactor:zoomFactor Near:center]; | ||
47 | + } | ||
48 | +} | ||
49 | + | ||
50 | +-(CALayer*) layer | ||
51 | +{ | ||
52 | + return container; | ||
53 | +} | ||
54 | + | ||
55 | +-(void) drawRect: (CGRect)rect | ||
56 | +{ | ||
57 | + NSLog(@"Map layers not currently supported using quartz renderer"); | ||
58 | +} | ||
59 | + | ||
14 | @end | 60 | @end |
@@ -7,18 +7,13 @@ | @@ -7,18 +7,13 @@ | ||
7 | // | 7 | // |
8 | 8 | ||
9 | #import <Foundation/Foundation.h> | 9 | #import <Foundation/Foundation.h> |
10 | +#import <QuartzCore/QuartzCore.h> | ||
10 | 11 | ||
11 | - | ||
12 | -// Support for this is not yet implemented. | ||
13 | - | ||
14 | -@protocol RMMapLayer<NSObject> | ||
15 | - | ||
16 | -@optional | 12 | +@interface RMMapLayer : CALayer |
13 | +{ | ||
14 | +} | ||
17 | 15 | ||
18 | - (void)moveBy: (CGSize) delta; | 16 | - (void)moveBy: (CGSize) delta; |
19 | - (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center; | 17 | - (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center; |
20 | 18 | ||
21 | --(void) drawRect: (CGRect)rect; | ||
22 | --(CALayer*) layer; | ||
23 | - | ||
24 | -@end | 19 | +@end |
@@ -10,4 +10,30 @@ | @@ -10,4 +10,30 @@ | ||
10 | 10 | ||
11 | @implementation RMMapLayer | 11 | @implementation RMMapLayer |
12 | 12 | ||
13 | +- (id) init | ||
14 | +{ | ||
15 | + if (![super init]) | ||
16 | + return nil; | ||
17 | + | ||
18 | + return self; | ||
19 | +} | ||
20 | + | ||
21 | +- (id)initWithLayer:(id)layer | ||
22 | +{ | ||
23 | + if (![super initWithLayer:layer]) | ||
24 | + return nil; | ||
25 | + | ||
26 | + return self; | ||
27 | +} | ||
28 | + | ||
29 | +- (void)moveBy: (CGSize) delta | ||
30 | +{ | ||
31 | + | ||
32 | +} | ||
33 | + | ||
34 | +- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center | ||
35 | +{ | ||
36 | + | ||
37 | +} | ||
38 | + | ||
13 | @end | 39 | @end |
MapView/Map/RMMarker.h
0 → 100644
1 | +// | ||
2 | +// RMMarker.h | ||
3 | +// MapView | ||
4 | +// | ||
5 | +// Created by Joseph Gentle on 13/10/08. | ||
6 | +// Copyright 2008 __MyCompanyName__. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import <UIKit/UIKit.h> | ||
10 | +#import "RMMapLayer.h" | ||
11 | + | ||
12 | +@interface RMMarker : RMMapLayer { | ||
13 | + | ||
14 | +} | ||
15 | + | ||
16 | +- (id) initWithCGImage: (CGImageRef) image; | ||
17 | +- (id) initWithUIImage: (UIImage*) image; | ||
18 | + | ||
19 | +@end |
MapView/Map/RMMarker.m
0 → 100644
1 | +// | ||
2 | +// RMMarker.m | ||
3 | +// MapView | ||
4 | +// | ||
5 | +// Created by Joseph Gentle on 13/10/08. | ||
6 | +// Copyright 2008 __MyCompanyName__. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import "RMMarker.h" | ||
10 | + | ||
11 | + | ||
12 | +@implementation RMMarker | ||
13 | + | ||
14 | +- (id) initWithCGImage: (CGImageRef) image | ||
15 | +{ | ||
16 | + if (![super init]) | ||
17 | + return nil; | ||
18 | + | ||
19 | + self.contents = (id)image; | ||
20 | + | ||
21 | + return self; | ||
22 | +} | ||
23 | + | ||
24 | +- (id) initWithUIImage: (UIImage*) image | ||
25 | +{ | ||
26 | + return [self initWithCGImage: [image CGImage]]; | ||
27 | +} | ||
28 | + | ||
29 | +@end |
@@ -241,6 +241,8 @@ NSString * const RMMapImageLoadingCancelledNotification = @"MapImageLoadingCance | @@ -241,6 +241,8 @@ NSString * const RMMapImageLoadingCancelledNotification = @"MapImageLoadingCance | ||
241 | 241 | ||
242 | layer.actions=customActions; | 242 | layer.actions=customActions; |
243 | 243 | ||
244 | + layer.edgeAntialiasingMask = 0; | ||
245 | + | ||
244 | // NSLog(@"location %f %f", screenLocation.origin.x, screenLocation.origin.y); | 246 | // NSLog(@"location %f %f", screenLocation.origin.x, screenLocation.origin.y); |
245 | 247 | ||
246 | // NSLog(@"layer made"); | 248 | // NSLog(@"layer made"); |
@@ -31,8 +31,6 @@ | @@ -31,8 +31,6 @@ | ||
31 | id<RMTileSource> tileSource; | 31 | id<RMTileSource> tileSource; |
32 | 32 | ||
33 | NSCountedSet *images; | 33 | NSCountedSet *images; |
34 | - // This fixes an image resizing bug which causes thin lines along image borders | ||
35 | - BOOL nudgeTileSize; | ||
36 | } | 34 | } |
37 | 35 | ||
38 | -(id) initWithDelegate: (id) _delegate; | 36 | -(id) initWithDelegate: (id) _delegate; |
@@ -59,6 +57,4 @@ | @@ -59,6 +57,4 @@ | ||
59 | 57 | ||
60 | @property (assign, nonatomic, readwrite) id delegate; | 58 | @property (assign, nonatomic, readwrite) id delegate; |
61 | @property (retain, nonatomic, readwrite) id<RMTileSource> tileSource; | 59 | @property (retain, nonatomic, readwrite) id<RMTileSource> tileSource; |
62 | -@property (readwrite, assign, nonatomic) BOOL nudgeTileSize; | ||
63 | - | ||
64 | @end | 60 | @end |
@@ -18,7 +18,7 @@ | @@ -18,7 +18,7 @@ | ||
18 | 18 | ||
19 | @implementation RMTileImageSet | 19 | @implementation RMTileImageSet |
20 | 20 | ||
21 | -@synthesize delegate, nudgeTileSize, tileSource; | 21 | +@synthesize delegate, tileSource; |
22 | 22 | ||
23 | -(id) initWithDelegate: (id) _delegate | 23 | -(id) initWithDelegate: (id) _delegate |
24 | { | 24 | { |
@@ -28,7 +28,6 @@ | @@ -28,7 +28,6 @@ | ||
28 | tileSource = nil; | 28 | tileSource = nil; |
29 | self.delegate = _delegate; | 29 | self.delegate = _delegate; |
30 | images = [[NSCountedSet alloc] init]; | 30 | images = [[NSCountedSet alloc] init]; |
31 | - nudgeTileSize = YES; | ||
32 | return self; | 31 | return self; |
33 | } | 32 | } |
34 | 33 | ||
@@ -157,13 +156,6 @@ | @@ -157,13 +156,6 @@ | ||
157 | screenLocation.size.width = pixelsPerTile; | 156 | screenLocation.size.width = pixelsPerTile; |
158 | screenLocation.size.height = pixelsPerTile; | 157 | screenLocation.size.height = pixelsPerTile; |
159 | 158 | ||
160 | - // Corrects a bug in quartz's resizing code | ||
161 | - if (nudgeTileSize) | ||
162 | - { | ||
163 | - screenLocation.size.width += 0.5; | ||
164 | - screenLocation.size.height += 0.5; | ||
165 | - } | ||
166 | - | ||
167 | RMTileRect roundedRect = RMTileRectRound(rect); | 159 | RMTileRect roundedRect = RMTileRectRound(rect); |
168 | // The number of tiles we'll load in the vertical and horizontal directions | 160 | // The number of tiles we'll load in the vertical and horizontal directions |
169 | int tileRegionWidth = (int)roundedRect.size.width; | 161 | int tileRegionWidth = (int)roundedRect.size.width; |
@@ -80,6 +80,9 @@ | @@ -80,6 +80,9 @@ | ||
80 | B8C974CA0E8A9C30007D16AD /* RMCachedTileSource.h in Headers */ = {isa = PBXBuildFile; fileRef = B8C974C80E8A9C30007D16AD /* RMCachedTileSource.h */; }; | 80 | B8C974CA0E8A9C30007D16AD /* RMCachedTileSource.h in Headers */ = {isa = PBXBuildFile; fileRef = B8C974C80E8A9C30007D16AD /* RMCachedTileSource.h */; }; |
81 | B8C974CB0E8A9C30007D16AD /* RMCachedTileSource.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C974C90E8A9C30007D16AD /* RMCachedTileSource.m */; }; | 81 | B8C974CB0E8A9C30007D16AD /* RMCachedTileSource.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C974C90E8A9C30007D16AD /* RMCachedTileSource.m */; }; |
82 | B8C9787B0E8BE130007D16AD /* libMapView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B8C974590E8A19B2007D16AD /* libMapView.a */; }; | 82 | B8C9787B0E8BE130007D16AD /* libMapView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B8C974590E8A19B2007D16AD /* libMapView.a */; }; |
83 | + B8F3FC610EA2B382004D8F85 /* RMMapLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F3FC600EA2B382004D8F85 /* RMMapLayer.m */; }; | ||
84 | + B8F3FC640EA2E792004D8F85 /* RMMarker.h in Headers */ = {isa = PBXBuildFile; fileRef = B8F3FC620EA2E792004D8F85 /* RMMarker.h */; }; | ||
85 | + B8F3FC650EA2E792004D8F85 /* RMMarker.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F3FC630EA2E792004D8F85 /* RMMarker.m */; }; | ||
83 | B8FA92190E9315EC003A9FE6 /* RMLayerSet.h in Headers */ = {isa = PBXBuildFile; fileRef = B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */; }; | 86 | B8FA92190E9315EC003A9FE6 /* RMLayerSet.h in Headers */ = {isa = PBXBuildFile; fileRef = B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */; }; |
84 | B8FA921A0E9315EC003A9FE6 /* RMLayerSet.m in Sources */ = {isa = PBXBuildFile; fileRef = B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */; }; | 87 | B8FA921A0E9315EC003A9FE6 /* RMLayerSet.m in Sources */ = {isa = PBXBuildFile; fileRef = B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */; }; |
85 | /* End PBXBuildFile section */ | 88 | /* End PBXBuildFile section */ |
@@ -184,6 +187,9 @@ | @@ -184,6 +187,9 @@ | ||
184 | B8C974C80E8A9C30007D16AD /* RMCachedTileSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMCachedTileSource.h; sourceTree = "<group>"; }; | 187 | B8C974C80E8A9C30007D16AD /* RMCachedTileSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMCachedTileSource.h; sourceTree = "<group>"; }; |
185 | B8C974C90E8A9C30007D16AD /* RMCachedTileSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMCachedTileSource.m; sourceTree = "<group>"; }; | 188 | B8C974C90E8A9C30007D16AD /* RMCachedTileSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMCachedTileSource.m; sourceTree = "<group>"; }; |
186 | B8D27AFB0E8780CD00F596FE /* RMLatLong.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMLatLong.h; sourceTree = "<group>"; }; | 189 | B8D27AFB0E8780CD00F596FE /* RMLatLong.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMLatLong.h; sourceTree = "<group>"; }; |
190 | + B8F3FC600EA2B382004D8F85 /* RMMapLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMapLayer.m; sourceTree = "<group>"; }; | ||
191 | + B8F3FC620EA2E792004D8F85 /* RMMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMarker.h; sourceTree = "<group>"; }; | ||
192 | + B8F3FC630EA2E792004D8F85 /* RMMarker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMarker.m; sourceTree = "<group>"; }; | ||
187 | B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMLayerSet.h; sourceTree = "<group>"; }; | 193 | B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMLayerSet.h; sourceTree = "<group>"; }; |
188 | B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMLayerSet.m; sourceTree = "<group>"; }; | 194 | B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMLayerSet.m; sourceTree = "<group>"; }; |
189 | C7A967500E8412930031BA75 /* RMAbstractMecatorWebSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMAbstractMecatorWebSource.h; sourceTree = "<group>"; }; | 195 | C7A967500E8412930031BA75 /* RMAbstractMecatorWebSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMAbstractMecatorWebSource.h; sourceTree = "<group>"; }; |
@@ -411,9 +417,12 @@ | @@ -411,9 +417,12 @@ | ||
411 | B86F26A80E8742ED007A3773 /* Layers */ = { | 417 | B86F26A80E8742ED007A3773 /* Layers */ = { |
412 | isa = PBXGroup; | 418 | isa = PBXGroup; |
413 | children = ( | 419 | children = ( |
420 | + B8F3FC600EA2B382004D8F85 /* RMMapLayer.m */, | ||
414 | B86F26AC0E87442C007A3773 /* RMMapLayer.h */, | 421 | B86F26AC0E87442C007A3773 /* RMMapLayer.h */, |
415 | B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */, | 422 | B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */, |
416 | B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */, | 423 | B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */, |
424 | + B8F3FC620EA2E792004D8F85 /* RMMarker.h */, | ||
425 | + B8F3FC630EA2E792004D8F85 /* RMMarker.m */, | ||
417 | ); | 426 | ); |
418 | name = Layers; | 427 | name = Layers; |
419 | sourceTree = "<group>"; | 428 | sourceTree = "<group>"; |
@@ -499,6 +508,7 @@ | @@ -499,6 +508,7 @@ | ||
499 | B8C974B80E8A280A007D16AD /* RMMapContents.h in Headers */, | 508 | B8C974B80E8A280A007D16AD /* RMMapContents.h in Headers */, |
500 | B8C974CA0E8A9C30007D16AD /* RMCachedTileSource.h in Headers */, | 509 | B8C974CA0E8A9C30007D16AD /* RMCachedTileSource.h in Headers */, |
501 | B8FA92190E9315EC003A9FE6 /* RMLayerSet.h in Headers */, | 510 | B8FA92190E9315EC003A9FE6 /* RMLayerSet.h in Headers */, |
511 | + B8F3FC640EA2E792004D8F85 /* RMMarker.h in Headers */, | ||
502 | ); | 512 | ); |
503 | runOnlyForDeploymentPostprocessing = 0; | 513 | runOnlyForDeploymentPostprocessing = 0; |
504 | }; | 514 | }; |
@@ -630,6 +640,8 @@ | @@ -630,6 +640,8 @@ | ||
630 | B8C974BB0E8A36E5007D16AD /* RMMercator.c in Sources */, | 640 | B8C974BB0E8A36E5007D16AD /* RMMercator.c in Sources */, |
631 | B8C974CB0E8A9C30007D16AD /* RMCachedTileSource.m in Sources */, | 641 | B8C974CB0E8A9C30007D16AD /* RMCachedTileSource.m in Sources */, |
632 | B8FA921A0E9315EC003A9FE6 /* RMLayerSet.m in Sources */, | 642 | B8FA921A0E9315EC003A9FE6 /* RMLayerSet.m in Sources */, |
643 | + B8F3FC610EA2B382004D8F85 /* RMMapLayer.m in Sources */, | ||
644 | + B8F3FC650EA2E792004D8F85 /* RMMarker.m in Sources */, | ||
633 | ); | 645 | ); |
634 | runOnlyForDeploymentPostprocessing = 0; | 646 | runOnlyForDeploymentPostprocessing = 0; |
635 | }; | 647 | }; |
-
Please register or login to post a comment