0

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

    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 返回错误“加载图块时出错”。

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

谁能解释我为什么它不起作用?

4

1 回答 1

1

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

于 2013-10-28T12:20:45.010 回答