Map packages
Map packages are zip files which allow easy installation of custom maps, styles, elevation data, and other data. A map package consists of a set of files and an instruction file named “mapdetails.json”. You can download a sample package here or install it here.
Map packages can be easily installed from your server by linking to them as follows: “cartograph://www.myserver.com/mymappackage.cpkg”.
Packages can include:
- Metadata
- Elevation data
- BRouter routing data
- Folders
- Maps
- Styles
- Overlays
- Routing audio files
- Commands
- Creating packages directly in the Cartograph app
Creating the “mapdetails.json” file
The “mapdetails.json” file is a JSON file which contains instructions for the Cartograph app describing what files to install. We recommend to use Visual Studio Code (free, macOS, Windows) or Notepad++ (free, Windows only) for creating and editing the file. Before packaging the file we recommend to check it for error, e.g. by copying the contents to this website: “http://json.parser.online.fr/”.
The following code shows a full sample file. We will describe all elements later.
{
"version": 3,
"extracted_size_mb": 116,
"elevationdata": [
"*.hgt"
],
"maps": [
{
"type_hint": "folder",
"name": "Sample folder",
"uniqueId": "folder_abc",
"folder_key":""
},
{
"type_hint": "mapsforge",
"name": "Sample A",
"file": "sampleA.map",
"load_in_layer": -1,
"uniqueId": "mapA",
"folder_key":"folder_abc"
}
],
"styles": [
{
"type_hint": "folder",
"name": "Sample folder",
"uniqueId": "folder_abc",
"folder_key":""
},
{
"type_hint": "mapsforge",
"file": "samplestyle.zip",
"load_in_layer": 0,
"uniqueId": "abc",
"folder_key":"folder_abc"
}
],
"overlays": [
{
"type_hint": "folder",
"name": "Sample folder",
"uniqueId": "folder_abc",
"folder_key":""
},
{
"type_hint": "mapsforge",
"name": "Huts and shelters",
"file": "sampleA.poi",
"load": true,
"uniqueId": "abc1",
"folder_key":"folder_abc"
}
],
"routingaudio": [
{
"name": "Test audio package 1",
"folder": "testaudio"
}
],
"commands": [
{
"command": "mapposition",
"lat": 28.61,
"lon": -15.5,
"zoom": 10
},
{
"command": "preimportmessage",
"title": {
"default": "Information"
},
"message": {
"default": "The Sample Map package will now be installed. This can take several minutes.",
"de": "Das Sample Kartenpaket wird jetzt installiert."
}
},
{
"command": "postimportmessage",
"title": {
"default": "Success",
"de": "Erfolg"
},
"message": {
"default": "The Sample Map package has been installed.",
"de": "Das Sample Kartenpaket wurde installiert."
}
},
{
"command": "openwebsiteafterinstallation",
"url": "http://www.cartograph.eu"
}
]
}
Metadata
"version": 3,
"extracted_size_mb": 116
The metadata describes general information about the package. The “version” should always be “3”. The “extracted_size_mb” should approximately match the total size of all files included in the map package.
Elevation data
"elevationdata": [
"*.hgt",
"N12W13.hgt"
]
“elevationdata” contains a list of elevation data files. This can either be a concrete file (e.g. “N12W13.hgt”) or all files of a certain type in the map package (e.g. “*.hgt”).
BRouter routing data
"routingdata": [
"*.rd5",
"E10_N45.rd5"
]
“routingdata” contains a list of BRouter segment files (.rd5) for offline routing. As with elevation data, list single files (e.g. “E10_N45.rd5”) or all .rd5 files of the package ("*.rd5"). The app installs them into its BRouter segments folder, replacing a segment file with the same name.
Before a file is installed, the app checks:
- The file name: it must be a BRouter segment name such as “E10_N45.rd5” or “W5_S10.rd5”. Other files are skipped.
- The lookup version: the segment file must be built for the same BRouter lookup version as the app’s routing profiles. A file for another version is skipped, because BRouter would silently ignore it.
Skipped files are listed in the report shown after the installation; the rest of the package is still installed.
Folders
{
"type_hint": "folder",
"name": "Sample folder",
"uniqueId": "folder_abc",
"folder_key":""
}
Maps, Styles, and Overlays can be grouped by folders. A folder is defined by the “type_hint”: “folder” entry. The “uniqueId” must be a unique id for the folder. Using the uniqueId multiple times can lead to unexpected behavior. A recommended pattern for the uniqueId is “com.myserver.some_unique_id”. The “folder_key” contains the uniqueId of the parent folder and can be used for creating hierarchies of folders. If the folder_key is left empty then the folder is created in the root folder.
Maps
"maps": [
{
"type_hint": "folder",
"name": "Sample folder",
"uniqueId": "folder_abc",
"folder_key":""
},
{
"type_hint": "mapsforge",
"name": "Sample A",
"file": "sampleA.map",
"load_in_layer": -1,
"uniqueId": "mapA",
"folder_key":"folder_abc"
}
]
The “maps” element contains a list of folders and maps. The “type_hint” field contains a hint describing the map type:
- “mapsforge”: a Mapsforge map.
- “mapsforge_raster”: a Mapsforge raster map.
- “mbtiles_raster”: a MBTiles sqlite raster map.
- “mbtiles_mvt_vector”: a MBTiles sqlite vector map.
- “locus_sqlite”: a Locus sqlite map.
- “rmap”: a TwoNav RMAP raster map.
- “map”: all other map types.
- “garmin_img”: a Garmin IMG map.
- “garmin_gmap” a (zip-compressed) Garmin GMAP.
The optional “name” field sets the name the map is shown with in the app (e.g. “Germany – middle” instead of the file name). If it is missing, empty or the same as “file”, the map is named after its file.
The “load_in_layer” field indicates if the map should be automatically loaded after installation of the map package. A value greater than “-1” loads the map into that layer (replacing the map shown there); “-1” only imports the map.
Optionally, a map can get zoom limits:
{
"type_hint": "mapsforge",
"name": "Sample A",
"file": "sampleA.map",
"min_zoom": 8,
"max_zoom": 18,
"default_zoom": 12
}
“min_zoom” and “max_zoom” set the zoom range in which the map is shown; “limit_zoom” (true or false, default true) switches the limit on or off. Leave a value out to keep the map’s own limit. “default_zoom” sets the map’s default zoom (“Default zoom” in the map properties); leave it out to keep the map’s own.
Styles
"styles": [
{
"type_hint": "folder",
"name": "Sample folder",
"uniqueId": "folder_abc",
"folder_key":""
},
{
"type_hint": "mapsforge",
"file": "samplestyle.zip",
"load_in_layer": 0,
"uniqueId": "abc",
"folder_key":"folder_abc"
}
]
The “styles” element contains a list of folders and styles. The “type_hint” field contains a hint describing the style type:
- “mapsforge”: a Mapsforge style (render theme).
The “load_in_layer” field indicates if the style should be automatically loaded as default style after installation of the map package. A value greater than “-1” will load the style as default style.
Overlays
"overlays": [
{
"type_hint": "folder",
"name": "Sample folder",
"uniqueId": "folder_abc",
"folder_key":""
},
{
"type_hint": "mapsforge",
"name": "Huts and shelters",
"file": "sampleA.poi",
"load": true,
"uniqueId": "abc1",
"folder_key":"folder_abc"
}
]
The “overlays” element contains a list of folders and overlays. The “type_hint” field contains a hint describing the overlay type:
- “mapsforge”: a Mapsforge POI overlay.
The “load” field indicates if the overlay should be automatically loaded after installation of the map package. The value “true” means that the overlay will be automatically loaded.
The optional “name” field sets the name the overlay is shown with in the app. If it is missing or empty, the overlay is named after its file.
Routing audio files
"routingaudio": [
{
"name": "Test audio package 1",
"folder": "testaudio"
}
]
The “routingaudio” element contains information about routing audio files. Please refer to the Audio Packages page for details.
Commands
"commands": [
{
"command": "mapposition",
"lat": 28.61,
"lon": -15.5,
"zoom": 10
},
{
"command": "preimportmessage",
"title": {
"default": "Information"
},
"message": {
"default": "The Sample Map package will now be installed. This can take several minutes.",
"de": "Das Sample Kartenpaket wird jetzt installiert."
}
},
{
"command": "postimportmessage",
"title": {
"default": "Success",
"de": "Erfolg"
},
"message": {
"default": "The Sample Map package has been installed.",
"de": "Das Sample Kartenpaket wurde installiert."
}
},
{
"command": "openwebsiteafterinstallation",
"url": "http://www.cartograph.eu"
}
]
The “commands” element allows you to perform specific actions before and after the map package installation. The next sections describe each command in detail.
Map position
{
"command": "mapposition",
"lat": 28.61,
"lon": -15.5,
"zoom": 10
}
The “mapposition” element sets the map to this position after installation.
Message before installation
{
"command": "preimportmessage",
"title": {
"default": "Information"
},
"message": {
"default": "The Sample Map package will now be installed. This can take several minutes.",
"de": "Das Sample Kartenpaket wird jetzt installiert."
}
}
The “preimportmessage” shows a Ok/Cancel message dialog before map package installation. If “Cancel” is selected then the map package is not installed.
Message after installation
{
"command": "postimportmessage",
"title": {
"default": "Success",
"de": "Erfolg"
},
"message": {
"default": "The Sample Map package has been installed.",
"de": "Das Sample Kartenpaket wurde installiert."
}
}
The “postimportmessage” shows a message dialog after map package installation.
Open website url
{
"command": "openwebsiteafterinstallation",
"url": "http://www.cartograph.eu"
}
The “openwebsiteafterinstallation” opens a website after map package installation.
Add an offline elevation map
{
"command": "addofflinemap",
"type": "offline_slope",
"load_in_layer": 1
}
The “addofflinemap” command adds one of the maps the app computes from elevation data, for example from the elevation data in the same package. “type” is “offline_hgt” (hillshading), “offline_slope” (slope) or “offline_relief” (relief); “load_in_layer” works as for maps ("-1" = add the map without loading it).
The optional zoom keys “limit_zoom”, “min_zoom”, “max_zoom” and “default_zoom” work as for maps:
{
"command": "addofflinemap",
"type": "offline_hgt",
"limit_zoom": true,
"min_zoom": 8,
"max_zoom": 22,
"default_zoom": 8,
"load_in_layer": 4
}
The app has only one offline map of each type. If it already exists, the package’s zoom values replace the ones set there.
Create map packages directly in the Cartograph app
Map packages from existing maps, overlays, styles, elevation data, BRouter routing data (*.rd5) and routing audio files can be directly created in the Cartograph app in the main menu - “Tools” pane (Create map package, see Tools).