问题
I'm trying to load a tile source, but for some reason it doenst work. Here's my code:
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);
For some reason this works and i can see the map of lisbon offline.
if i switch the line
File myMapTileSource = new File(mapsDirectory.getPath()+File.separator+"Lisboa.gemf");
for
File myMapTileSource = new File(mapsDirectory.getPath()+File.separator+"Lissabon.osm");
it doenst work. It returns an error "Error loading tile" from MapTileFileArchiveProvider.
The gemf file was created in MOBAC. The osm file was downloaded from here.
Could anyone explain me why it doenst work?
回答1:
If you take a look at ArchiveFileFactory, you'll see that GEMF files are supported, but .osm files are not. I'm not sure what format .osm files are (maybe it's one of the supported formats and just needs to be renamed?)
来源:https://stackoverflow.com/questions/19634260/loading-tile-source