Authored by Joseph G

Partially implemented map layers.

Fixed the bug producing seams between tiles.
... ... @@ -8,18 +8,23 @@
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import "RMMercator.h"
#import "RMMapLayer.h"
@protocol RMMapLayer;
@class RMMapRenderer;
@interface RMLayerSet : NSObject
{
NSMutableArray *layers;
CALayer *container;
}
- (void)addAbove: (id)layer;
- (void)addBelow: (id)layer;
- (void)insertSublayer:(RMMapLayer*) layer below:(RMMapLayer*)sibling;
- (void)insertSublayer:(RMMapLayer*) layer above:(RMMapLayer*)sibling;
- (void)removeSublayer:(RMMapLayer*) layer;
- (void)moveToMercator: (RMMercatorPoint)mercator;
- (void)moveBy: (CGSize) delta;
- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center;
... ...
... ... @@ -11,4 +11,50 @@
@implementation RMLayerSet
- (id) init
{
if (![super init])
return nil;
container = [[CALayer alloc] init];
return self;
}
/*
- (void)insertSublayer:(RMMapLayer*) layer below:(RMMapLayer*)sibling;
- (void)insertSublayer:(RMMapLayer*) layer above:(RMMapLayer*)sibling;
- (void)removeSublayer:(RMMapLayer*) layer;
- (void)moveToMercator: (RMMercatorPoint)mercator;
*/
- (void)moveBy: (CGSize) delta
{
for (id layer in layers)
{
if ([layer respondsToSelector:@selector(moveBy:)])
[layer moveBy:delta];
}
}
- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center
{
for (id layer in layers)
{
if ([layer respondsToSelector:@selector(zoomByFactor:Near:)])
[layer zoomByFactor:zoomFactor Near:center];
}
}
-(CALayer*) layer
{
return container;
}
-(void) drawRect: (CGRect)rect
{
NSLog(@"Map layers not currently supported using quartz renderer");
}
@end
... ...
... ... @@ -7,18 +7,13 @@
//
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
// Support for this is not yet implemented.
@protocol RMMapLayer<NSObject>
@optional
@interface RMMapLayer : CALayer
{
}
- (void)moveBy: (CGSize) delta;
- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center;
-(void) drawRect: (CGRect)rect;
-(CALayer*) layer;
@end
@end
\ No newline at end of file
... ...
... ... @@ -10,4 +10,30 @@
@implementation RMMapLayer
- (id) init
{
if (![super init])
return nil;
return self;
}
- (id)initWithLayer:(id)layer
{
if (![super initWithLayer:layer])
return nil;
return self;
}
- (void)moveBy: (CGSize) delta
{
}
- (void)zoomByFactor: (float) zoomFactor Near:(CGPoint) center
{
}
@end
... ...
//
// RMMarker.h
// MapView
//
// Created by Joseph Gentle on 13/10/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "RMMapLayer.h"
@interface RMMarker : RMMapLayer {
}
- (id) initWithCGImage: (CGImageRef) image;
- (id) initWithUIImage: (UIImage*) image;
@end
... ...
//
// RMMarker.m
// MapView
//
// Created by Joseph Gentle on 13/10/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "RMMarker.h"
@implementation RMMarker
- (id) initWithCGImage: (CGImageRef) image
{
if (![super init])
return nil;
self.contents = (id)image;
return self;
}
- (id) initWithUIImage: (UIImage*) image
{
return [self initWithCGImage: [image CGImage]];
}
@end
... ...
... ... @@ -241,6 +241,8 @@ NSString * const RMMapImageLoadingCancelledNotification = @"MapImageLoadingCance
layer.actions=customActions;
layer.edgeAntialiasingMask = 0;
// NSLog(@"location %f %f", screenLocation.origin.x, screenLocation.origin.y);
// NSLog(@"layer made");
... ...
... ... @@ -31,8 +31,6 @@
id<RMTileSource> tileSource;
NSCountedSet *images;
// This fixes an image resizing bug which causes thin lines along image borders
BOOL nudgeTileSize;
}
-(id) initWithDelegate: (id) _delegate;
... ... @@ -59,6 +57,4 @@
@property (assign, nonatomic, readwrite) id delegate;
@property (retain, nonatomic, readwrite) id<RMTileSource> tileSource;
@property (readwrite, assign, nonatomic) BOOL nudgeTileSize;
@end
... ...
... ... @@ -18,7 +18,7 @@
@implementation RMTileImageSet
@synthesize delegate, nudgeTileSize, tileSource;
@synthesize delegate, tileSource;
-(id) initWithDelegate: (id) _delegate
{
... ... @@ -28,7 +28,6 @@
tileSource = nil;
self.delegate = _delegate;
images = [[NSCountedSet alloc] init];
nudgeTileSize = YES;
return self;
}
... ... @@ -157,13 +156,6 @@
screenLocation.size.width = pixelsPerTile;
screenLocation.size.height = pixelsPerTile;
// Corrects a bug in quartz's resizing code
if (nudgeTileSize)
{
screenLocation.size.width += 0.5;
screenLocation.size.height += 0.5;
}
RMTileRect roundedRect = RMTileRectRound(rect);
// The number of tiles we'll load in the vertical and horizontal directions
int tileRegionWidth = (int)roundedRect.size.width;
... ...
... ... @@ -80,6 +80,9 @@
B8C974CA0E8A9C30007D16AD /* RMCachedTileSource.h in Headers */ = {isa = PBXBuildFile; fileRef = B8C974C80E8A9C30007D16AD /* RMCachedTileSource.h */; };
B8C974CB0E8A9C30007D16AD /* RMCachedTileSource.m in Sources */ = {isa = PBXBuildFile; fileRef = B8C974C90E8A9C30007D16AD /* RMCachedTileSource.m */; };
B8C9787B0E8BE130007D16AD /* libMapView.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B8C974590E8A19B2007D16AD /* libMapView.a */; };
B8F3FC610EA2B382004D8F85 /* RMMapLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F3FC600EA2B382004D8F85 /* RMMapLayer.m */; };
B8F3FC640EA2E792004D8F85 /* RMMarker.h in Headers */ = {isa = PBXBuildFile; fileRef = B8F3FC620EA2E792004D8F85 /* RMMarker.h */; };
B8F3FC650EA2E792004D8F85 /* RMMarker.m in Sources */ = {isa = PBXBuildFile; fileRef = B8F3FC630EA2E792004D8F85 /* RMMarker.m */; };
B8FA92190E9315EC003A9FE6 /* RMLayerSet.h in Headers */ = {isa = PBXBuildFile; fileRef = B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */; };
B8FA921A0E9315EC003A9FE6 /* RMLayerSet.m in Sources */ = {isa = PBXBuildFile; fileRef = B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */; };
/* End PBXBuildFile section */
... ... @@ -184,6 +187,9 @@
B8C974C80E8A9C30007D16AD /* RMCachedTileSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMCachedTileSource.h; sourceTree = "<group>"; };
B8C974C90E8A9C30007D16AD /* RMCachedTileSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMCachedTileSource.m; sourceTree = "<group>"; };
B8D27AFB0E8780CD00F596FE /* RMLatLong.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMLatLong.h; sourceTree = "<group>"; };
B8F3FC600EA2B382004D8F85 /* RMMapLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMapLayer.m; sourceTree = "<group>"; };
B8F3FC620EA2E792004D8F85 /* RMMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMMarker.h; sourceTree = "<group>"; };
B8F3FC630EA2E792004D8F85 /* RMMarker.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMMarker.m; sourceTree = "<group>"; };
B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMLayerSet.h; sourceTree = "<group>"; };
B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RMLayerSet.m; sourceTree = "<group>"; };
C7A967500E8412930031BA75 /* RMAbstractMecatorWebSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RMAbstractMecatorWebSource.h; sourceTree = "<group>"; };
... ... @@ -411,9 +417,12 @@
B86F26A80E8742ED007A3773 /* Layers */ = {
isa = PBXGroup;
children = (
B8F3FC600EA2B382004D8F85 /* RMMapLayer.m */,
B86F26AC0E87442C007A3773 /* RMMapLayer.h */,
B8FA92170E9315EC003A9FE6 /* RMLayerSet.h */,
B8FA92180E9315EC003A9FE6 /* RMLayerSet.m */,
B8F3FC620EA2E792004D8F85 /* RMMarker.h */,
B8F3FC630EA2E792004D8F85 /* RMMarker.m */,
);
name = Layers;
sourceTree = "<group>";
... ... @@ -499,6 +508,7 @@
B8C974B80E8A280A007D16AD /* RMMapContents.h in Headers */,
B8C974CA0E8A9C30007D16AD /* RMCachedTileSource.h in Headers */,
B8FA92190E9315EC003A9FE6 /* RMLayerSet.h in Headers */,
B8F3FC640EA2E792004D8F85 /* RMMarker.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
... ... @@ -630,6 +640,8 @@
B8C974BB0E8A36E5007D16AD /* RMMercator.c in Sources */,
B8C974CB0E8A9C30007D16AD /* RMCachedTileSource.m in Sources */,
B8FA921A0E9315EC003A9FE6 /* RMLayerSet.m in Sources */,
B8F3FC610EA2B382004D8F85 /* RMMapLayer.m in Sources */,
B8F3FC650EA2E792004D8F85 /* RMMarker.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
... ...