TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
Use MBMapSnapshotter to retrieve an image from the MapBox.com static image service with your custom style. After downloading the image the class will call a block with a MBSnapshot Object from witch you can retrieve the UIImage itself and also get the CGPoint in the image for a give CLLocationCoordinate2d (useful to draw custom markers or routes on it)
Make this repo a submodule of your git repository or just fork it. You'll also need AFNetworking. I'm currently working on a CocoaPods Podspec
#import <CLLocation/CLLocation.h>
#import "AFNetworking.h"
#import "MBMapSnapshotter.h"
- (void)takeSnapshot {
CLLocationCoordinate2D coordnate = CLLocationCoordnate2DMake(52.516667, 13.383333); //Berlin
MBMapSnapshotter *mapSnapShotter = [[MBMapSnapshotter alloc]init];
[mapSnapShotter setMapName:@"examples.map-9ijuk24y"];
[mapSnapShotter getSnapshotWithCenter:coordinate size:CGSizeMake(480, 320) zoomLevel:14 finishingBlock:^(MBSnapshot *snapshot, NSError *error) {
if (error){
NSLog(@"Error %@", error);
} else {
[_imageView setImage snapshot.image];
}
}];
}
You can also use
- (CGPoint)pointForCoordinate:(CLLocationCoordinate2D)coordinateto get a point in the image for a give coordinate.