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);
            }
        });

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source