public
Created

MKOverlayView Fucntions

  • Download Gist
MKOverlayviewFucntions.m
Objective-C
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
 
- (BOOL)canDrawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale {
NSURL* fileURL = [(HeatMap*)self.overlay localUrlForStyle:@"classic" withMapRect:mapRect andZoomScale:zoomScale];
if([[NSFileManager defaultManager] fileExistsAtPath:[fileURL path]])
return YES;
[(HeatMap*)self.overlay fetchFileForStyle:@"classic" withMapRect:mapRect zoomScale:zoomScale completion:^{
[self setNeedsDisplayInMapRect:mapRect zoomScale:zoomScale];
}];
return NO;
}
 
/**
* If the above method returns YES, this method performs the actual screen render
* of a particular tile.
*
* You should never perform long processing (HTTP requests, etc.) from this method
* or else your application UI will become blocked. You should make sure that
* canDrawMapRect ONLY EVER returns YES if you are positive the tile is ready
* to be rendered.
*/
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context {
NSURL* fileURL = [(HeatMap*)self.overlay localUrlForStyle:@"classic" withMapRect:mapRect andZoomScale:zoomScale];
NSData *imageData = [NSData dataWithContentsOfURL:fileURL ];
if (imageData != nil) {
UIImage *img = [UIImage imageWithData:imageData];
// Perform the image render on the current UI context
UIGraphicsPushContext(context);
[img drawInRect:[self rectForMapRect:mapRect] blendMode:kCGBlendModeNormal alpha:1.0];
UIGraphicsPopContext();
}
 
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.