Skip to content

How to create your own offline maps

MichelTenVoorde edited this page May 21, 2014 · 19 revisions

c:geo supports mapsforge maps of version 0.3.0.

Some offline maps are downloadable on the mapsforge website. If you would like to have different maps here is a how-to. The how-to is written for systems with Java already installed.

The basic idea is to download an OSM map and to convert it with Osmosis and the mapsforge plugin to a mapsforge map.

For examples we'll use the country of Guinea, because you'll definitely want to go caching there!

Here is how it is done in detail. It looks complicated, but if you follow this guide step by step it should be no problem at all. And if you have done it once, you will never want to do anything else :-)

Installation of tools in Windows

Tested with Windows XP SP3, Java 7, Osmosis 0.40.1, mapsforge map writer 0.3.0

  • Download the latest version of Osmosis
  • Unpack it anywhere you like. In the newly created folder there is a folder named bin where you will find the Osmosis executable osmosis.bat
  • Create this folder structure: C:\Documents and Settings\(your Username)\Application Data\Openstreetmap\Osmosis\Plugins\ ("Application Data" can be named otherwise, in German Windows it is called "Anwendungsdaten" for example)
  • Download the mapsforge-map-writer jar and put it in the Plugins folder you just created

Installation of tools in Linux

Tested with Ubuntu 12, OpenJDK 1.6, perl v5.14.2, Osmosis 0.40.1, mapsforge map writer 0.3.0

  • Download Osmosis 0.40.1 (it does not work with the latest version of Osmosis on Ubuntu 13.04)
  • Unpack it anywhere you like. In the newly created folder there is a folder named bin where you will find the Osmosis executable
  • Create this folder: ~/.openstreetmap/osmosis/plugins/
  • Download the mapsforge-map-writer jar and put it in the plugins folder you just created

Download osm map

Download a map file (.osm.bz2) from cloudmade and unpack it. Windows: 7-zip is able to unpack .bz2 files. Linux: use bunzip2 to unpack.

Check this list for other download sites.

Determine the bounding box

For some reason the mapsforge plugin always needs a bounding box. It cannot determine it itself, even if you want the whole OSM map converted.

The bounding box defines the rectangle to cut out of the OSM map. It is specified within the conversion command. You'll need the values in this order, comma separated and without any spaces: minimum latitude, minumum longitude, maximum latitude, maximum longitude. Or, easier to remember: max. south, west, north, east.

For example, the bounding box for guinea in whole is: 7.193553,-15.076250,12.676221,-7.641071

You can also cut out any city or area you like.

There are several ways to get the values. Here are three of them:

Via .poly file

You need a running version of Perl.

  • Download poly2bb.pl
  • Change the last command (printf) of poly2bb.pl to printf "%f,%f,%f,%f", $miny, $minx, $maxy, $maxx;
  • Download the .poly file from cloudmade
  • Run this: poly2bb.pl guinea.poly

Via OpenStreetMaps

This is the best visual way to determine the bounding box.

  • Go to openstreetmaps.org
  • Navigate to where your bounding box is on the map
  • Hit "Export"
  • Click on the link under the four values for lat- and longitude, it says "choose manually" or the like.
  • Draw a rectangle for your bounding box
  • Download the map in XML format
  • leave this page open, as you need the displayed values later

Via Google Maps

Right click on the map and choose "What's here?". The latitude and longitude of the point you clicked on is displayed in the search box. Note the four needed values (max. south, west, north, east).

You don't have to be too perfect with this. Just get the rough coordinates.

Convert it!

  • Unpack the .osm file
  • Open a terminal window. In Windows press Windows-R, type "cmd", hit enter
  • Convert with: path\to\osmosis-0.40.1\bin\osmosis --read-xml file=guinea.osm --mapfile-writer file=guinea.map bbox=7.193553,-15.076250,12.676221,-7.641071

Use the map with c:geo

Now copy the .map file to your Android device into one of these directories:

  • /sdcard/.cgeo/
  • /sdcard/Locus/mapsVector/ - this way you can share it with Locus
  • /sdcard/mfmaps/

Open c:geo, go to the Settings, scroll down to the maps section, hit the button with the three dots and select your map. Voilà!

Troubleshooting

  • OutOfMemory: tell Osmosis to use more heap memory by running set JAVACMD_OPTIONS="-Xmx2G" on Windows or export JAVACMD_OPTIONS="-Xmx2G" on Linux before starting up the process
  • OutOfMemory again: you can tell the mapsforge plugin to use the hard disk instead of the RAM by adding type=hd after the bbox parameter in the conversion command used above. Drawback: this will slow down things.

Further Reading

Clone this wiki locally