Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
MKOverlayView Fucntions
- (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
[img drawInRect:[self rectForMapRect:mapRect] blendMode:kCGBlendModeNormal alpha:1.0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.