加载平铺源

时间:2013-10-28 12:00:41

标签: android openstreetmap tile osmdroid

我正在尝试加载一个磁贴源,但由于某种原因它会起作用。 这是我的代码:

    final IRegisterReceiver registerReceiver = new SimpleRegisterReceiver(this);

    // Create a custom tile source
    final ITileSource tileSource = TileSourceFactory.MAPNIK;

    // Create a file cache modular provider
    final TileWriter tileWriter = new TileWriter();
    final MapTileFilesystemProvider fileSystemProvider = new MapTileFilesystemProvider(registerReceiver, tileSource);

    File myMapTileSource = new File(mapsDirectory.getPath()+File.separator+"Lisboa.gemf");

    // Create an archive file modular tile provider
    IArchiveFile[] archives = { ArchiveFileFactory.getArchiveFile(myMapTileSource) };
    MapTileFileArchiveProvider fileArchiveProvider = new MapTileFileArchiveProvider(registerReceiver, tileSource, archives);

    // Create a download modular tile provider
    final NetworkAvailabliltyCheck networkAvailablilityCheck = new NetworkAvailabliltyCheck(this);
    final MapTileDownloader downloaderProvider = new MapTileDownloader(tileSource, tileWriter, networkAvailablilityCheck);

    // Create a custom tile provider array with the custom tile source and the custom tile providers
    final MapTileProviderArray tileProviderArray = new MapTileProviderArray(tileSource, registerReceiver, new MapTileModuleProviderBase[] { fileSystemProvider, fileArchiveProvider, downloaderProvider });

    // Create the mapview with the custom tile provider array
    mMapView = new MapView(this, 256, new DefaultResourceProxyImpl(this), tileProviderArray);
    mMapView.setUseDataConnection(false);

出于某种原因,这可行,我可以看到里斯本离线地图。

如果我切换线

File myMapTileSource = new File(mapsDirectory.getPath()+File.separator+"Lisboa.gemf");

File myMapTileSource = new File(mapsDirectory.getPath()+File.separator+"Lissabon.osm");
它是最重要的工作。它从MapTileFileArchiveProvider返回错误“Error loading tile”。

gemf文件是在MOBAC中创建的。 osm文件是从here下载的。

有人能解释一下为什么它会起作用吗?

1 个答案:

答案 0 :(得分:1)

如果您查看ArchiveFileFactory,您会看到支持GEMF文件,但不支持.osm文件。我不确定.osm文件的格式是什么(也许它是支持的格式之一,只需要重命名?)