Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // MapView.m
- // Campus Tour
- //
- // Created by trey t on 11/16/08.
- // Copyright 2008 __MyCompanyName__. All rights reserved.
- //
- #import "MapView.h"
- #import "TiledDelegate.h"
- #import <QuartzCore/CoreAnimation.h>
- @implementation MapView
- @synthesize pdf, scale, popUpIndex, sfMuni, map;
- +(Class)layerClass
- {
- return [CATiledLayer class];
- }
- -(id)initWithFrame:(CGRect)r
- {
- self = [super initWithFrame:r];
- if(self != nil)
- {
- CATiledLayer *l = (CATiledLayer*)self.layer;
- l.levelsOfDetail = 15;
- l.levelsOfDetailBias = 12;
- }
- return self;
- }
- - (id)init
- {
- return [self initWithFrame:CGRectZero];
- }
- -(void)zoomIn{
- // NSLog(@"zoom");
- // zoom = scale;
- // self.layer.transform = CATransform3DMakeScale(zoom, zoom, 1.0f);
- }
- -(void)drawRect:(CGRect)r
- {
- }
- - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
- CGContextSaveGState(ctx);
- CGContextTranslateCTM( ctx, 0,layer.bounds.size.height);
- CGContextScaleCTM(ctx, 1.0, -1.0);
- CGContextSaveGState(ctx);
- CGRect pageRect = CGPDFPageGetBoxRect(map, kCGPDFCropBox);
- NSString *path = [[NSBundle mainBundle] pathForResource:@"NTMap2" ofType:@"pdf"];
- NSURL *docURL = [NSURL fileURLWithPath:path];
- sfMuni = CGPDFDocumentCreateWithURL((CFURLRef)docURL);
- if(NULL == map) {
- map = CGPDFDocumentGetPage(self.sfMuni, 1);
- }
- self.layer.bounds = CGRectMake(0.0f, 0.0f, CGRectGetWidth(pageRect),CGRectGetHeight(pageRect));
- CGFloat x = CGRectGetWidth(self.layer.bounds) * self.layer.anchorPoint.x;
- CGFloat y = CGRectGetHeight(self.layer.bounds) * self.layer.anchorPoint.y;
- //868x816
- tiledLayer.position = CGPointMake(x * zoom, y * zoom);
- tiledLayer.transform = CATransform3DMakeScale(zoom, zoom, 1.0f);
- CGContextDrawPDFPage(ctx, map);
- CGContextRestoreGState(ctx);
- }
- -(void)dealloc {
- CGPDFDocumentRelease(pdf);
- [super dealloc];
- }
- @end
Add Comment
Please, Sign In to add comment