MBTiles map files tools for iOS.
Small library to manipulate .mbtiles map file database. For example use the latests vector tiles from OpenMapTiles. This library supports all kind of tiles sets, jpg, png and pbf.
Link requirements You need to link this library with sqlite3 and MapKit.
MBTilesReader is the easiest way to access to the database content.
Init the reader with your .mbtiles path
NSString *filePath = @"my_file_path";
MBTilesReader *reader = [[MBTilesReader alloc] initWithFilePath:filePath];
The reader needs to be opened before any use. If the .mbtiles file is not correctely set, this methods will inform you about the problem
if ([reader open]) {
NSLog(@"Good, use the reader");
}
else
{
NSLog(@"Error, verify your file path and content");
}
Access to all your .mbtiles metadata
MBTilesFormat format = [reader format];
if (format == MBTilesFormatPBF) {
NSLog(@"Good, got vector tiles");
}
else {
NSLog(@"Error, not vector tiles DB");
}
Access to the tiles bytes by fetching them with x, y, z
NSData *tile = [reader tileForX:0 Y:0 Z:1];
NSLog(@"got tile 0/0/1, length %@ bytes", @(tile.length));