Skip to content

Instantly share code, notes, and snippets.

@syshen
Created October 25, 2013 17:00
Show Gist options
  • Select an option

  • Save syshen/7158055 to your computer and use it in GitHub Desktop.

Select an option

Save syshen/7158055 to your computer and use it in GitHub Desktop.
//
// 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