Last active
December 26, 2015 20:28
-
-
Save ccabanero/7208451 to your computer and use it in GitHub Desktop.
iOS - Adding TileStream cache to MapKit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface MapViewController() | |
@property (nonatomic, weak) IBOutlet MKMapView *mapView; | |
@property (nonatomic, strong) MKTileOverlay *overlay; | |
@end | |
@implementation MapViewController | |
@synthesize mapView = _mapView; | |
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil | |
{ | |
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | |
if (self) { | |
// Custom initialization | |
} | |
return self; | |
} | |
- (void)viewDidLoad | |
{ | |
NSString *template = @"http://1.2.3.4:8888/v2/bangladesh_districts/{z}/{x}/{y}.png"; | |
self.overlay = [[MKTileOverlay alloc] initWithURLTemplate:template]; | |
self.overlay.canReplaceMapContent = YES; | |
[self.mapView addOverlay:self.overlay level:MKOverlayLevelAboveLabels]; | |
} | |
- (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id<MKOverlay>)overlay { | |
return [[MKTileOverlayRenderer alloc] initWithOverlay:overlay]; | |
} | |
- (void)didReceiveMemoryWarning | |
{ | |
[super didReceiveMemoryWarning]; | |
self.overlay = nil; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment