What are stored maps?

When MGmaps displays a map on your handheld device, it needs to locate the map tiles (bitmap images) corresponding to your position at the correct zoom level.  It can download these map tiles over the telephone network from map sources such as Yahoo maps.  Or, it can find these map tiles on the internal memory of your handheld device.  When MGmaps finds the map tiles in the internal memory rather than the network, we say that MGmaps is working in stored map mode.

Why should I use stored map mode?

If you have an unlimited data plan with your mobile telephone provider, then you don't mind downloading map tiles as you use MGmaps.  If you are concerned about the data usage, or if you are roaming outside of your provider's territory, then you want to minimize the network traffic.  Then you might want to use stored map mode, because then the map tiles are found in your handheld device's internal memory, not on the network.  And if you are in a location where there is no network coverage, say in a remote forest, then you have no choice but to use stored maps.

I regularly travel around the world on business.  I always feel safe knowing that I can use MGmaps to find where I am and where I want to go, even if I cannot access the telephone network.  In fact I only use MGmaps in stored map mode.  On my Blackberry I already have other mapping applications such as Blackberry Maps, Google Maps, and TeleNav (for driving directions), each requiring access to the telephone data network.  MGmaps in stored map mode is like having a standalone GPS receiver.

What do I do to use stored map mode?

The downside of using stored maps is that you have to do some preparation.  Your device memory is not large enough to hold all of the world's maps, so you have to decide which parts of the world you want to store in your phone's memory.  You need to use a personal computer, not your phone, to get the map tiles from the Internet, then copy them to your phone's internal memory.  Luckily the MGmaps community has provided the tools to make this easy to do.

Downloading map tiles to your personal computer

You need to get the map tiles off the internet and onto your hard disk.  There is a handy program to do this, found at http://www.mgmaps.com/cache/.

In the following steps, I will pretend that I will be travelling to London and Paris.  I will install the map tiles for these cities on my Blackberry 8310.  Details may be slightly different for your handheld device.

Choose the regions of the world that you need maps for

Use the handy interactive web page found at http://www.mgmaps.com/cache/, by clicking the Map Creation Tool link.  This takes you to Shustrik's web page at http://www.mapcacher.com/.  You should see a screen like this:

This tool does not actually download any map tiles. It creates a short text file with extension .MAP that your store on your PC. This .MAP file contains the details of the area that you want.  The warnings at the bottom about high detail level freezing your computer are not correct.  This step is very fast.

Choose the type of map from the dropdown list.  Here we will use Google Road Maps.  I don't think the Level of Detail has any effect.

You then navigate in the map as you do with any embedded Google map control, by dragging in the map to move it, and clicking the + or - zoom controls to zoom in and out.  We now find the area of London that we are interested in:

This contains the central part of London.  We now define the region that we are interested in, by clicking the mouse in each corner of the region.  You can define a polygon by clicking in several places.  We will just define an approximate square.

Note that the map creation tool has two unrelated zoom levels.  The current zoom level is displayed just below the map, and refers to the zoom level of the displayed map (12 in the example above).  You will typically use a much lower zoom level on the displayed map than what you want to download.  The actual highest zoom level that you download is specified in the Zoom Level input boxes.

The map creation tool has a warning that it may take a long time to run.  This is not true, because this program does not actually download any map tiles.  It only creates a .MAP file that defines the areas and zoom levels that are to be downloaded later.  However you should be aware that the map tiles can take a lot of storage space.  All of North American, including Canada and the Caribbean up to zoom level 8, takes 24 MB in 2800 files and 350 folders.  All of western Europe up to zoom level 10 takes 200 MB and 20,000 files.

We are going to choose a maximum zoom level of 15 for the greater London area chosen above.  Enter 0 and 15 in the Zoom Level input boxes.

Now click the Generate button.  Your web browser offers to save a file for you:

If you are using Internet Explorer, then click the Save button on the dialog box.  I suggest that you change the name to something more descriptive.  In this example, I will call this map file London_roads_zoom15.map.  I also suggest that you keep these map files in a single directory. 

The files are very small.  Here is the content of the file that we just saved:

GoogleMap
00-15: 51.44033450559848, -0.263671875 : 51.549763523502534, 0.0439453125

The first line says what type of maps are to be downloaded.  Subsequent lines give the latitude and longitude of the region.  You can edit these files, say using Notepad.  Just be sure to keep the field separators (colons, commas).  For example, we could change the desired zoom level by changing the 00-15 to 00-16, say, or 00-09.

Download the map tiles

We haven't even got the map tiles yet!  That comes next.  You need to download another MGmaps tool from the download page http://www.mgmaps.com/cache/.  Here you select gMapMaker.  Go ahead and click the link.  It will download an executable file that installs the application on your PC (sorry Mac people).  You now run this program on your PC, from the Start Menu.  It is called gMapMaker.

For Operating Mode, choose "MGMaps mode, download tiles using a .map file".  Hash size of 97 is good.  The top line, Cache Folder, says where you want to store your map tile files.

Getting back to the gMapMaker application, enter a name for the Cache Folder in which you want to store the map tiles.  Here we have chosen F:\MgMapsCache\London_Roads_Z15.  You now click the GO button on gMapMaker.  It will open a dialog box, asking you to select the .MAP file that describes the region.  Here you choose the file London_roads_zoom15.map that you saved earlier using the map creation tool.  I suggest that you keep these files in a different directory than where you keep the map tiles.  When you click the Open button to select the file, gMapMaker begins to download the map tiles in parallel.  This can take minutes or hours.  When it is finished, click the Close button.  The cache folder has been filled with the following subdirectories:

You can see that it creates a directory MGMapsCache, and a number of subdirectories, one for each zoom level.  Inside each of these are more subdirectories, and finally the actual map tile files with extension .MGM.  These files are actually PNG files internally, 256 by 256 pixels in size.  You can use IrfanView to look at them (http://www.irfanview.com/).  Here is one of the tiles from zoom level 15:

At this point, you can repeat the above two steps: (1) create a .MAP file defining the region of interest, and (2) download the map tiles.  You can see from the map tile above that you will need a higher zoom level for central London.  You would create a smaller region using the map creation tool, specifying a maximum zoom level of 17.  Then download these tiles into a new subdirectory called London_Roads_z17 parallel to the previously created London_roads_z15.  For the imaginary trip here, we would also create similar subdirectories for the central Paris and the surrounding area.

Upload the map tile files to your handheld device

You now need to copy these map tile files from your PC to your mobile device.  This step is a bit specific to your actual telephone.  Most smart phones use a USB cable to connect to the PC, and the internal memory card appears on the PC as a hard disk structure.  When I plug my Blackberry into the USB cable, the device asks if I want to activate mass storage mode; I answer Yes.  The SD card now appears in the Windows Explorer like a disk drive.  Alternatively, you might remove an SD card from the phone and plug it into a card reader on your PC; that too should look like a disk drive on the PC.

You might see something like this using Windows Explorer on your PC:

Note that there is a top level directory called Blackberry.  I assume that this was created when I formatted the SD card in the device.  I think all content has to be within this directory.  Your device may differ.

There is already a subdirectory called MGMapsCache, because I created this previously.  If this is your first time using stored maps, then use Explorer to create a new subdirectory of this name.  For Windows XP, click the Blackberry folder, then select File/New/Folder and name it MGMapsCache.  Windows Vista has a slightly different way to create a new folder.  This folder will hold all of the map tiles so that MGmaps can find them.  But first you must copy the map tiles from the PC to the mobile phone.

Using another instance of Windows Explorer, find the folder on your hard drive where gMapMaker copied them.  In my case, they are subfolders within F:\MgMapsCache\.  Let us copy one of the London map sets that we created above.  We only want to copy the content that is inside the MGMapsCache subdirectory within London_Roads_Z14, i.e. the contents of F:\MgMapsCache\London_Roads_Z14\MgMapsCache.  It should look like this:

In the right hand pane, click on one of the folders, e.g. GoogleMap_0.  Then press control-A to select all of the folders.  Then drag all of these folders to the mobile phone's SD card contents, inside folder MGMapsCache that you previously created.  It may take a few minutes to transfer the files.  Copy the cache.conf file too -- more on that file later.

Then repeat this step for all of the other map regions that you created previously.  We will copy London_Roads_Z16 and London_Roads_Z17 which contain the central part of London at higher resolution.  The beauty of the naming convention for the map tiles is that you can mix all these different map areas and zoom levels together, and MGmaps can figure it out.  They can overlap each other in any way, yet you always get the highest resolution map that is available for your current location.

Now your mobile phone SD card contents should look like this:

You can see that in addition to the GoogleMap_0 etc. folders that we copied above, I already had some other folders called GoogleHyb and GoogleSat.  These were created using different selections of the Type of Map in the Map Creation Tool.

You have now copied the map tiles from your PC to the memory card of your mobile phone.  Now it is finally time to run MGmaps on your phone.

Installing and running MGmaps on your mobile phone

There are two ways to install the executable code of MGmaps on your mobile phone.  (1) Over the air (OTA) in which you use the Internet connection of your phone to transfer the files over your carrier's network, or (2) from your PC.  The Blackberry has an application loader that runs on the PC and can transfer the code to your phone.  Your phone will differ, so I won't discuss method (2) any further.

To install MGmaps OTA, open the web browser on your smart phone.  Then navigate to http://wap.mgmaps.com/ and click on the version that is appropriate for your phone.  Your phone will then follow some sort of process to verify that you want to install an application.  The Blackberry asks if you want to give it Trusted Application status (yes).  The program must have access to the memory card.

Then you run MGmaps on your mobile phone.  On the Blackberry, it creates an icon that can be seen on the Applications page, in this case the one below the film reel.  Click this icon to start MGmaps.  The first time, it may ask for permission to access the internet and your SD card storage.  (In newer versions, it also wants to take a snapshot of your screen, I believe to create a transparency effect for the splash screen -- you can enter either yes or no to this question.)

You then need to bring up the menu.  I think this differs between mobile phones.  I will explain this for the Blackberry.  Press the Space bar to bring up the menu tree.  Navigate this menu to find Settings, using the trackball to move and clicking to select.

The actual path depends on which version of MGmaps you are using.  This shows 1.41, the development version as of July 2009.  You select Settings/Map/Stored Maps to get this:

Click on the two boxes labelled Stored Maps and Offline Mode.  The first box enables the use of stored map mode.  The second box prohibits the use of the mobile phones Internet connect to download live maps.  You can leave this unchecked if you want.  Since I don't want to incur big data charges with my carrier while roaming to London, I use Offline Mode.

This is where you tell MGmaps where you have stored the map tile files.  Note that the name here, SDCard/Blackberry/MGMapsCache, is slightly different than the same directory as seen from the PC.  The naming convention will vary by phone type.  Click Browse to select the location where you copied the maps, then save it.  On the Blackberry, you use the Back key to go to the previous screen.

You then choose another menu item, Map Types.  You want to tell MGmaps which types of maps it can look for.  I have selected three types of Google Maps.  You can rotate through different map types by pressing a shortcut key, the Zero key on the Blackberry.

You also have to select your GPS device.  My Blackberry 8310 has an internal GPS.  There are other choices which will depend on your device.

There are a bunch of other options for setting things up.  Here I enable mobile tracking, so the map follows me as I move.  There are other options under Display.  See what works best for you.

And now you can back out of the menus (roll trackball left for version 1.41).  The GPS should lock onto your position, et voila!  You zoom in with the "I" key, and out with the "O" key (In/Out, get it?).  If you try to zoom in too far, or you have not loaded maps for your location, you will see red X's on your screen.  Zoom out all the way.  If you have loaded the world map up to zoom level 6 as I suggested above, then you will eventually see a map.  If not, then there is a problem with your settings.  You can see the scale size of zoom level 15; the scale of 100 meters (300 feet for Americans) is seen in the lower left corner.  That is why you need zoom level 16 or more for central London.

Because we are dealing with tens of thousands of map tiles, copying them to the mobile phone can be a lengthy process.  There is a setup time to access each file, even if it is very small.  Even deleting the map files on your mobile phone can take a long time -- 45 minutes to delete 1.5 GB of map tiles.  My Blackberry loads about 3 files per second.

You can automate the copying to the mobile phone using a DOS script on a Windows machine.  Use Notepad to create a file called upload.bat or something similar.  Copy the following into the file and save it.  You will have to change srcdir and destdir to match your locations.  And of course the individual names will be different, unless you have created the same maps that I have.  Then open a DOS shell (Start/Run/cmd), use CD to navigate to where upload.bat is, and enter "upload" to run the batch file.  You can also double-click the file name in Windows Explorer and it will run, but it will disappear when it has finished. 

set srcdir=F:\MGMapsCache
set destdir=I:\Blackberry\MGMapsCache

rmdir "%destdir%"\ /s
mkdir "%destdir%"

rem xcopy "%srcdir%\NorthAmerica_Streets_Z8\MGMapsCache\*.*" "%destdir%" /s /y
xcopy "%srcdir%\World_Streets_Z6\MGMapsCache\*.*" "%destdir%" /s /y
rem xcopy "%srcdir%\Rome_Z15\MGMapsCache\*.*" "%destdir%" /s /y
rem xcopy "%srcdir%\Rome_Z17\MGMapsCache\*.*" I:\Blackberry\MGMapsCache /s /y
rem xcopy "%srcdir%\Naples_Z17\MGMapsCache\*.*" "%destdir%" /s /y
rem xcopy "%srcdir%\Ischia_Z17\MGMapsCache\*.*" "%destdir%" /s /y
xcopy "%srcdir%\London_Roads_Z14\MGMapsCache\*.*" "%destdir%" /s /y
xcopy "%srcdir%\London_Roads_Z16\MGMapsCache\*.*" "%destdir%" /s /y
xcopy "%srcdir%\London_Roads_Z17\MGMapsCache\*.*" "%destdir%" /s /y
xcopy "%srcdir%\Barcelona_streets_Z16\MGMapsCache\*.*" "%destdir%" /s /y
rem xcopy "%srcdir%\Paris_Roads_Z15\MGMapsCache\*.*" "%destdir%" /s /y
xcopy "%srcdir%\Europe_Z10\MGMapsCache\*.*" "%destdir%" /s /y
Note the rmdir and mkdir commands near the top.  These delete the entire MGMapsCache tree on the smartphone.  This leaves the tree empty so that you can copy only the map tiles that you want. If you simply want to add additional map tiles to what is already there, put "rem" in front of these two lines.

 

cache.conf file

gMapMaker creates a file cache.conf in each MGMapsCache folder that it copies map tiles into.  This file is a text file that is used by MGMaps on your mobile phone.  On your phone there will be only one copy of this file, and it will be changed by MGMaps.  It doesn't matter if you overwrite this file with ones from your PC, as long as tiles_per_file is the same for every folder.  The contents of cache.conf look like this:

version=3
tiles_per_file=1
hash_size=97
center=0.000000,0.000000,1,GoogleMap

tiles_per_file is greater than 1 if you compress the map tiles using MapAlive.  I do not recommend doing this, because the techniques I described above about copying different folders for different cities will not work, because the filenames are no longer unique.

hash_size is the number in gMapMaker, and should be left at 97 for all your map tiles.

The last line is the current latitude, longitude, zoom and map type.  This line is changed by MGMaps when you exit the program on your smart phone, so that it restarts at the previous map and zoom.