Created
October 25, 2013 17:00
-
-
Save syshen/7158055 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // | |
| // SSViewController.m | |
| // MyMapBox | |
| // | |
| // Created by syshen on 10/23/13. | |
| // Copyright (c) 2013 syshen. All rights reserved. | |
| // | |
| #import "SSViewController.h" | |
| #import <MapBox/MapBox.h> | |
| @interface SSViewController () <RMTileCacheBackgroundDelegate> | |
| @property (nonatomic, weak) IBOutlet RMMapView *mapView; | |
| @end | |
| @implementation SSViewController | |
| - (void)viewDidLoad | |
| { | |
| [super viewDidLoad]; | |
| RMTileCache *tileCache = [[RMTileCache alloc] initWithExpiryPeriod:3100000]; | |
| RMMapBoxSource *tileSource = [[RMMapBoxSource alloc] initWithMapID:@"syshen.map-tq7kavku"]; | |
| self.mapView.tileSource = tileSource; | |
| self.mapView.tileCache = tileCache; | |
| self.mapView.centerCoordinate = CLLocationCoordinate2DMake(37.7812, -122.413); | |
| self.mapView.zoom = 15.0; | |
| tileCache.backgroundCacheDelegate = self; | |
| [tileCache beginBackgroundCacheForTileSource:self.mapView.tileSource southWest:CLLocationCoordinate2DMake(-122.433, 37.739) northEast:CLLocationCoordinate2DMake(-122.395, 37.800) minZoom:13 maxZoom:18]; | |
| } | |
| - (void) viewDidAppear:(BOOL)animated { | |
| [super viewDidAppear:animated]; | |
| } | |
| - (void)didReceiveMemoryWarning | |
| { | |
| [super didReceiveMemoryWarning]; | |
| // Dispose of any resources that can be recreated. | |
| } | |
| - (void) tileCache:(RMTileCache *)tileCache didBeginBackgroundCacheWithCount:(int)tileCount forTileSource:(id<RMTileSource>)tileSource { | |
| NSLog(@"Begin background cache: %d", tileCount); | |
| } | |
| - (void) tileCache:(RMTileCache *)tileCache didBackgroundCacheTile:(RMTile)tile withIndex:(int)tileIndex ofTotalTileCount:(int)totalTileCount { | |
| NSLog(@"Begine background cache tile for index: %d", tileIndex); | |
| } | |
| - (void) tileCacheDidCancelBackgroundCache:(RMTileCache *)tileCache { | |
| NSLog(@"background cache canceled"); | |
| } | |
| - (void) tileCacheDidFinishBackgroundCache:(RMTileCache *)tileCache { | |
| NSLog(@"background cache finish"); | |
| } | |
| @end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment