1#import "AIRMapOverlayRenderer.h"
2#import "AIRMapOverlay.h"
3
4@implementation AIRMapOverlayRenderer
5
6- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {
7    UIImage *image = [(AIRMapOverlay *)self.overlay overlayImage];
8
9    CGContextSaveGState(context);
10
11    CGImageRef imageReference = image.CGImage;
12
13    MKMapRect theMapRect = [self.overlay boundingMapRect];
14    CGRect theRect = [self rectForMapRect:theMapRect];
15
16    CGContextRotateCTM(context, M_PI);
17    CGContextScaleCTM(context, -1.0, 1.0);
18    CGContextTranslateCTM(context, 0.0, -theRect.size.height);
19    CGContextAddRect(context, theRect);
20    CGContextDrawImage(context, theRect, imageReference);
21
22    CGContextRestoreGState(context);
23}
24
25- (BOOL)canDrawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale {
26    return [(AIRMapOverlay *)self.overlay overlayImage] != nil;
27}
28
29@end
30
31