简体   繁体   中英

MKTileOverlay in iOS 7 with mbtiles database

Is there a way by which I can directly use mbtiles database with MKTileOverlay without using a third party framework like MapBox or any other?

Right now, I have the tiles stored in a folder structure and the code I am using is below:

NSString *tileDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Tiles"];
NSString *tileDirectoryURL = [NSURL fileURLWithPath:tileDirectory isDirectory:YES];
NSString *tileURL = [NSString stringWithFormat:@"%@Z{z}/{y}_{x}.png", tileDirectoryURL];
tileOverlay = [[MKTileOverlay alloc] initWithURLTemplate:tileURL];
[tileOverlay setGeometryFlipped:YES];
[mainMapView addOverlay:tileOverlay];

But now I want to have a tiles.mbtiles sqlite database instead of the files in folders.

Please suggest me how can I do this. How do I initialize the MKTileOverlay object if I choose to use sqlite database. How will I put {x},{y},{z}.

I went through the documentation of MKTileOverlay and found that :

- (void)loadTileAtPath:(MKTileOverlayPath)path result:(void (^)(NSData *tileData, NSError *error))result

can be used but I am not able to understand how can I use it? If any one can please give ma a short example then it would be very helpful.

You could take a look at how this project does it…

https://github.com/t2wu/OSMMapKit

It doesn't seem to be finished yet but it should get you on the right path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM