Posts Tagged offline maps
I like Google Maps. What I don’t like — these maps are not available offline, which is exactly the time I need them most of all, far away from home and, probably, without a reliable phone data connection. Actiually, there might be some way to cache Google Maps, and I’m sure my phone does that, but I could not figure out how to get it working reliably, it feels like cache time is very limited, maybe hours or minutes — definitely not enough for real-life applications.
Recently I’ve found Maverick from Code Sector. It shows the map, works with GPS and compass and does pretty much everything Google Maps does, and also it can cache and use offline maps. There’s even explanation about how to download and where to save map tiles.
However, the map downloading software just downloads everything within the selected region and did not care much if there’s real map data or just plain sea (Japan consists of many islands), so I did not want to end up with numerous files with blue color inside and used my own downloader.
Fortunately, I have already downloaded plenty of Google Maps for offline use with some other software, so I did not want to redownload everything again, and just needed a way to reconvert and save map tiles appropriately for Maverick.
Maverick uses the following path for Google Maps : /sdcard/maverick/tiles/googlemaps/0/0/0.png.tile, I just need to figure out what are those numbers and how should I place my files there.
The first number is obviously zoom factor. Google Maps saves maps according to the zoom factor, the lowest zoom level is 0, which gives us 20 = 1 tile, covering the whole globe. Next zoom level 1 splits the globe into 2×2 = 4 tiles. Zoom level 2 results in 4×4 = 16 tiles. And for any given zoom level z we can calculate the number of tiles covering the whole globe as NxN, where N = 2z. Google Maps has only 17 zoom levels for maps, and maybe 19 for satellite images.
If we have latitude and longutide, the tile number can be calculated with the following code snippet (in Python) :
def coord2tile(lat_deg, lon_deg, zoom): lat_rad = math.radians(lat_deg) n = 2.0 ** zoom xtile = int((lon_deg + 180.0) / 360.0 * n) ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n) return(xtile, ytile)
And in the Maverick the X coordinate becomes the folder name (inside the zoom folder) and Y coordinate becomes the file name (sans ‘.png.tile’ extension), so the proper place for Google Maps tile is /sdcard/maverick/tiles/googlemaps/ZOOM/X/Y.png.tile
The whole world at zoom levels 4~6 does not take much space at all, whole Japan at zoom levels upto 13 is about 200mb, and some areas of interest, like Tokyo and Osaka at zoom levels up to 15 add about 800mb, so whole map of Japan takes about 1GB of map tiles and fits to 4GB of memory card (it takes more space on SD card because of large cluster size).
Predownloaded Google Maps
Whole world, zoom 4~6 (17mb) :
Japan, zoom 7~12 (140mb) :
Japan, zoom 13 (200mb) :
Levels 14 and beyond take too much space, so you may download partial maps around the places you like yourself.
Also, be careful, if your SD card is formatted with 16kb cluster size, maps tend to occupy 3-4 times as much space as their size. 1GB of maps took about 4GB of space on my device, so if your SD card is small, it might be a good idea to format with 2~4k cluster size.