我正在尝试使用 Route-Me 使用离线 MBTiles 数据库。为了实现这一点,我使用 Landez ,而这又取决于 MBUtil 。
现在,我得到的只是一个灰色屏幕,针脚位于适当的位置。这是打印到控制台的内容:
initializing memory cache <RMMemoryCache: 0x4e42e50> with capacity 32
Opening database at /Users/chrislong/Library/Application Support/iPhone Simulator/4.3.2/Applications/E53BC885-1B02-4B06-B45B-408EB9A147DE/Documents/MapOpenStreetMap.sqlite
Map contents initialised. view: MapView at 0,0-320,411 tileSource <RMCachedTileSource: 0x4e428b0> renderer <RMCoreAnimationRenderer: 0x4e13dc0>
initializing memory cache <RMMemoryCache: 0x5929930> with capacity 32
Opening database at /Users/chrislong/Library/Application Support/iPhone Simulator/4.3.2/Applications/E53BC885-1B02-4B06-B45B-408EB9A147DE/Documents/MapMBTilestiles.mbtiles.sqlite
Warning: I could not find the column named 'tile_data'.
Warning: I could not find the column named 'tile_data'.
Warning: I could not find the column named 'tile_data'.
Warning: I could not find the column named 'tile_data'.
Map contents initialised. view: MapView at 0,0-320,411 tileSource <RMCachedTileSource: 0x592a400> renderer <RMCoreAnimationRenderer: 0x5925770>
值得注意的是,该文件名为
tiles.mbtiles
,而不是 MapMBTilestiles.mbtiles.sqlite
,并且存储在包的根目录中,而不是 Documents
文件夹中。这是我用来制作
mapView
和加载数据库的代码:CLLocationCoordinate2D center = {50, 50};
self.mapView = [[[RMMapView alloc] initWithFrame:self.view.frame] autorelease];
self.mapView.backgroundColor = [UIColor blackColor];
self.mapView.delegate = self;
NSURL *tilePath = [[NSBundle mainBundle] URLForResource:@"tiles" withExtension:@"mbtiles"];
RMMBTilesTileSource *tiles = [[[RMMBTilesTileSource alloc] initWithTileSetURL:tilePath] autorelease];
[self.mapView.contents removeAllCachedImages];
self.mapView.contents = [[[RMMapContents alloc] initWithView:self.mapView tilesource:tiles centerLatLon:center zoomLevel:0.0 maxZoomLevel:[tiles maxZoom] minZoomLevel:[tiles minZoom] backgroundImage:nil] autorelease];
[self addMarkers];
Route-Me 显然根本没有读取文件;即使我完全删除数据库,我也会得到相同的日志输出。 IOW,问题可能是由于 Route-Me 无法找到该文件。任何帮助,将不胜感激!
最佳答案
checkout - (RMTileImage *)tileImage:(RMTile)tile from MapView->Map->Tile Source
在更改行之前,我遇到了由 map2sqlite 生成的 sqlite db 的一些问题:
NSInteger y = pow(2, zoom) - tile.y - 1;
至:
NSInteger y = tile.y;
我现在正在使用 tilemill 生成的数据库,所以我没有进一步深入研究,但如果我是你,我会在一些调试语句中折腾并查看它正在寻找的瓷砖与你的数据库中的瓷砖布局是什么.我认为这可能与 mbtiles 平铺顺序与 osm 平铺顺序有关。
——兰迪
关于iphone - 在 Route-Me 中使用离线数据库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6590195/