video 1 does not support memory map error code example

Example: osmdroid offline map does not show

//super important to configure some of the mapsforge settings first in your activity onCreate:
MapsForgeTileSource.createInstance(this.getApplication());

//
File[] maps = null;  //TODO scan/prompt for map files (.map)

XmlRenderTheme theme = null; //null is ok here, uses the default rendering theme if it's not set
try {
//this file should be picked up by the mapsforge dependencies
	theme = new AssetsRenderTheme(getContext().getApplicationContext(), "renderthemes/", "rendertheme-v4.xml");
	//alternative: theme = new ExternalRenderTheme(userDefinedRenderingFile);
} catch (Exception ex) {
	ex.printStackTrace();
}

MapsForgeTileSource fromFiles = MapsForgeTileSource.createFromFiles(maps, theme, "rendertheme-v4");
MapsForgeTileProvider forge = new MapsForgeTileProvider(
	new SimpleRegisterReceiver(getContext()),
	fromFiles, null);

mMapView.setTileProvider(forge);

//now for a magic trick
//since we have no idea what will be on the
//user's device and what geographic area it is, this will attempt to center the map
//on whatever the map data provides
mMapView.post(
        new Runnable() {
            @Override
            public void run() {
                mMapView.zoomToBoundingBox(fromFiles.getBoundsOsmdroid(), false);
            }
        });

Tags:

Java Example