Skip to content
Go to file

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Codename Offline Maps Provider

This library includes a MapProvider that works with the Codename One MapComponent class to provide support for offline maps.




  • Should work on all CN1 platforms (J2ME, iOS, Android, BlackBerry, and Windows Phone).
  • Works with the Codename One MapComponent
  • Supports the CN1Tiles format for importing map data. Note: This format was created specifically for use by this module, however, you can use the CN1TileConverter tool to convert the more common MBTiles format into a CN1Tiles file that can be used with this module.


  1. CN1JTar Library


  1. Install the CN1JTar library into your project.
  2. Copy the CN1OfflineMaps.cn1lib file into the lib directory of your codename one project.
  3. Right click on your project in the project explorer (if using Netbeans) and click "Refresh Libs".

Code Example

MBTilesProvider provider; 
if ( MBTilesProvider.isLoaded("output.cn1tiles") ){
    // The map named "output.cn1tiles" is already loaded…
    // We can just create a provider for this map.
    provider = new MBTilesProvider("output.cn1tiles");
} else {
    // The map specified hasn't been created yet…
    // We can create this in a number of ways including:
    // From resources (i.e. include the output.cn1tiles file as part of 
    // the application bundle):
        provider = MBTilesProvider.createFromResource("/output.cn1tiles");
    } else if ( CREATE_FROM_FILE ){
        // Or from the file system
        provider = MBTilesProvider.createFromFile("/path/to/output.cn1tiles");
    } else if ( CREATE FROM INPUTSTREAM ){
        InputStream is = getInputStream();  // Could be from a server
        provider = MBTilesProvider.create("output.cn1tiles", is);

// With our loaded MBTilesProvider let's create a MapComponent and add it to a form:
MapComponent map = new MapComponent(provider,, provider.minZoomLevel(), false);
Form hi = new Form("Offline Map Test");
hi.setLayout(new BorderLayout());
hi.addComponent(BorderLayout.CENTER, map);;

How to Create an Offline Map

This libray is only useful if you are able to create the cn1tiles file to begin with. In order to do this you will need the following tools:

  1. TileMill - A Desktop application that allows you to create maps using public data sources like Open Street Maps.
  2. CN1TileConverter - A Desktop utility that converts mbtiles files to cn1tiles format. This was designed specifically to be used with this library.

Step 1: Create your map in TileMill.

Step 2: Export your map as an mbtiles file.

Step 3: Convert your .mbtiles file to a .cn1tiles file using CN1TileConverter

Step 4: Load the .cn1tiles file inside your Codename One application usin the MBTilesProvider class. You can either embed the file as part of your application source, or place it on a server and have your application download it on first load (or some other logical time).


Offline Maps for Codename One



No releases published


No packages published


You can’t perform that action at this time.