[iOS SDK] Offline-Mapping first conclusions

After a few days of researching about how to implement offline maps for iOS SDK, i’ve found that OpenStreetMaps seems to be the best choice, though it is difficult to find tutorials or clear documentation about how to implement them. An OSM-based library that suited my needs very well is Mapbox. As we can see in the basic tutorial, Mapbox uses the .mbtiles map format, and here comes the tricky part.

A .mbtiles file is a SQLite database containing two tables: One with metadata (like name of the map, or version) and another with raw tiles, stored in a BLOB field in PNG format, and properly indexed.

So the first challenge is to generate your own .mbtiles file for your custom map. To face this, i’ve found many useful links:

– The TileMill tool, which is basic for generating mbtiles files

– You can open a SQLite connection to the .mbtiles file with your favourite SQLite client (mine is Navicat), and explore its content to understand the structure.

Pedro’s Tech Mumblings, that explains how to do various operations with .mbtiles files

The exporting episode of the crashcourse, which explains how to export a map step by step

– I’ve also found that MOBAC (Mobile Atlas Creator) can manage .mbtiles files. Have a look at my MOBAC tutorial, and use the “mbtiles sqlite format” instead of “OsmDroid ZIP”. Rest of the steps are similar. Do not forget to use PNG tiles!

This post has been useful aswell, because it does an interesting thing (creating the .mbtiles from a hi-res image using self-made a python script), and has a lot of detailed info about the .mbtiles format, and useful scripts for extracting & creating mbtiles files. Helps a lot with the learning.

This example from Mapbox official site, and this one were also helpful to paint markers on the offline map and handle events like single tap, customize the bubble and handle its events, etc.

And that’s pretty much what i’ve discovered after these few days working. I’ll keep on posting my progresses 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s