在 Route-Me 中使用离线数据库
我正在尝试使用 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 找不到该文件造成的。任何帮助将不胜感激!
I'm trying to use an offline MBTiles database using Route-Me. To accomplish this, I'm using Landez, which in turn depends on MBUtil.
Right now, all I get is a gray screen with the pins in their proper locations. Here's what gets printed to the console:
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>
It's worth noting that the file is named tiles.mbtiles
, not MapMBTilestiles.mbtiles.sqlite
, and is stored in the root of the bundle, not the Documents
folder.
Here's the code I use to make the mapView
and load the database:
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 is obviously not reading the file at all; even if I delete the database entirely, I get the same log output. IOW, the problem is probably as a result of Route-Me being unable to find the file. Any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看 - (RMTileImage *)tileImage:(RMTile)tile from MapView->Map->Tile Source
我对 map2sqlite 生成的 sqlite 数据库遇到了一些问题,直到我将行:
更改为:
我正在使用tilemill生成的数据库现在,所以我还没有进一步深入研究它,但如果我是你,我会扔进一些调试语句,看看它正在寻找什么图块以及数据库中的图块布局 是。我认为这可能与 mbtiles 平铺顺序与 osm 平铺顺序有关。
——兰迪
Check out - (RMTileImage *)tileImage:(RMTile)tile from MapView->Map->Tile Source
I was having some issues with sqlite db's generated by map2sqlite until I changed the line:
to:
I'm using tilemill generated db's right now, so I haven't dug into it further, but I'd toss in some debug statements if I were you and look at what tiles its looking for vs what the tile layout in your db is. I think it might have to to do with mbtiles tiling order vs osm's tiling order.
-- Randy
事实上,我昨天就在努力解决这个问题。
似乎有两种不同的图块格式,google xyz 和 openstreetmap 使用的 TMS。
兰迪突出显示的行
正在将一种转换为另一种。例如,我正在使用 Maperative 构建地图,然后将其导出到目录中的图块,最后使用 mb-util 生成tiles.mbtiles 文件。
我遇到了完全相同的问题,进行兰迪上面建议的更改并且它有效。
但最终我编写了一个 php 脚本来将图块的文件名重命名为正确的。老实说,我仍然不太清楚哪些软件以什么格式导出。我认为 mbtiles 应该是 TMS,这意味着 Route-me 是 xyz,但我可能是错的。
I actually wrestled with this very problem yesterday.
There seem to be two different tile formats out there, google xyz and TMS which is used by openstreetmap.
The line Randy highlighted
Is converting one to the other. So for example I am building my map using Maperative, then exporting it to tiles in a directory and finally using mb-util to generate the tiles.mbtiles file.
And I was having the exact same issue, make the changes that Randy suggested above and it works.
ultimately however I wrote a php script to rename the filenames of the tiles to be correct. I'll be honest I still haven't quite got my head around which pieces of software are exporting in what format. I think mbtiles is supposed to be TMS which implies that route-me is xyz, but I could be wrong on that.
我在上面进行了更改,但随后在地图居中时遇到了一些问题。经过相当长的一段时间的工作后,我将您上面提到的那一行更改为:
希望这可以帮助任何也遇到麻烦的人。
I made your change above but then had some problems centering the map. After working on it for quite some time I change the line you mention above to this:
Hope this helps anyone also having trouble.