Online maps
The Cartograph app can be extended with custom online maps. How to use online maps in the app (the built-in list, WMS, WMTS, projections, scripts): Online maps.
- Install user created maps.
- Manually adding an online map.
- Manually adding a WMS online map.
- Creating online map installation files.
Install user created online maps
The following table lists ready-to-install online maps:
| Name | Type | Install |
|---|---|---|
| Google maps (road, terrain, satellite) | Raster | Install |
| IGN-France | Raster | Install |
| Baidu (China, road, satellite) | Raster | Install |
| Gaode (China, road, satellite) | Raster | Install |
| SwissTopo (Switzerland) | Raster | Install |
| Yandex (Russia, road, satellite) | Raster | Install |
| Strava Heatmap (Instructions) | Raster | Install |
Ready-to-install online maps.
Manually adding an online map
The easiest way: the online map creation tool. Enter the tile server address (or pick one of its examples), check the preview, and install the map with one tap.
Manually adding a WMS online map
Use the online map creation tool with the map type “WMS” and the address of the WMS service. In the app, choose the layer in the map’s options. You can also add a WMS or WMTS service directly in the app: WMS, WMTS.
Creating online map definition files
Online map definition files contain a list of online map definitions which can be easily installed from a web server by creating a link of the format “cartograph://www.myserver.com/myonlinemaps.onlinemap”. The file extension of definition files must be “*.onlinemap”.
The following code shows an example definition file which creates a folder containing two maps:
{
"version": 3,
"folders":[
{
"name": {
"default": "Example online maps folder"
},
"description": {
"default": ""
},
"folder_key":"",
"key":"example_online_maps"
}
],
"maps": [
{
"name": {
"default": "OpenStreetMap Example Map",
"de": "OpenStreetMap Beispielkarte"
},
"description": {
"default": ""
},
"type": "onlinemap",
"url": "http://tile.openstreetmap.org/{z}/{x}/{y}.png?tilesize={ts}",
"attribution": "© OpenStreetMap contributors\nhttp://www.openstreetmap.org/copyright",
"defaultLatitude": 51.47,
"defaultLongitude": 0,
"defaultZoom": 1,
"minZoom": 0,
"maxZoom": 22,
"projection": "EPSG_4326",
"headers": [
{
"key": "User-Agent",
"value": "My user-agent"
}
],
"unique_id": "example.openstreetmap.org",
"folder_key":"example_online_maps"
},
{
"name": {
"default": "NASA WMS map"
},
"description": {
"default": ""
},
"type": "wms",
"url": "",
"service_url": "https://neo.sci.gsfc.nasa.gov/wms/wms?version=1.3.0&service=WMS&request=GetCapabilities",
"wms_version": "1.1.1",
"attribution": "© NASA",
"defaultLatitude": 51.47,
"defaultLongitude": 0,
"defaultZoom": 1,
"minZoom": 0,
"maxZoom": 22,
"projection": "EPSG_4326",
"headers": [
{
"key": "User-Agent",
"value": "My user-agent"
}
],
"unique_id": "example.neo.sci.gsfc.nasa.gov",
"folder_key":"example_online_maps"
}
]
}
Folders
The “folders” element contains a list of folders which can be used for grouping the maps. Each folder has an unique “key” which must be unique in the app. A recommended format for the key is “com.myserver.some_unique_string”. The “folder_key” field can be used for creating hierarchies of folders (if left empty then the folder is placed in the root folder).
Maps
The “maps” element contains a list of online maps. The following fields are available:
- “name”: The name of the map.
- “description”: A description of the map.
- “type”: The map type:
- “onlinemap”: A raster tiles online map providing png, jpg, or bmp images.
- “onlinemap_bing”: A raster map whose server uses quadkey urls ("{quadkey}"). The name is historical: Bing Maps itself has been retired.
- “onlinemap_mvt”: A vector tiles online map providing Mapbox vector tiles.
- “wms”: A WMS (web map service) map.
- “wmts”: A WMTS map.
- “url” (optional for WMS maps): The server url for requesting tiles. Since Cartograph 3.0.8 variable formats {x} and {$x} are supported. The following variables are available:
- “{x}”: The x coordinate of the tile.
- “{y}”: The y coordinate of the tile.
- “{z}”: The zoom level.
- “{invY}”: TMS y coordinate (inverse “{y}”).
- “{-y}”: Same as “{invY}”.
- “{ts}” (optional): The tile size.
- “{quadkey}”, “{quad}” (type “onlinemap_bing” only): The tile quad key.
- “{serverpart}”, “{s}”: Always replaced by “a”.
- “{minlon}”, “{maxlat}”, “{maxlon}”, “{minlat}”, “{bbox}”: The bounding box coordinates (WMS maps only). “{bbox}” is the WMS “BBOX” value: “min longitude,min latitude,max longitude,max latitude” (in metres for Web Mercator), or “min latitude,min longitude,max latitude,max longitude” when the address contains “version=1.3.0” and the CRS is geographic (for example “crs=EPSG:4326”), as WMS 1.3.0 requires.
- “service_url” (WMS and WMTS maps): The GetCapabilities URL of the service. For a WMS it usually has the following format: “https://neo.sci.gsfc.nasa.gov/wms/wms?version=1.3.0&service=WMS&request=GetCapabilities”.
- “wms_version” (WMS maps only): “1.1.1” or “1.3.0”.
- “layer”, “style”, “tile_matrix_set”, “format” (WMTS maps only, optional): The layer, style, tile matrix set and image format to select. The app reads the capabilities when the map is first loaded and builds the tile URL itself, so “url” can be left out.
- “attribution”: The copyright/attribution for the map.
- “defaultLatitude”: The default latitude position of the map.
- “defaultLongitude”: The default longitude position of the map.
- “defaultZoom”: The default zoom level.
- “minZoom”: The minimum zoom level supported by the map.
- “maxZoom”: The maximum zoom level supported by the map.
- “projection”: Only sets the units of the bounding box placeholders of WMS maps (“EPSG_4326” for degrees). It is not the projection of the tiles; z/x/y maps can leave it out.
- “tile_grid” (type “onlinemap” only, Cartograph Maps 4.1.4 and newer): The tile grid of a z/x/y map that isn’t Web Mercator: “world_mercator” (Yandex), “gcj02” (Gaode, Tencent, Google China) or “bd09” (Baidu). Without it the map is Web Mercator. See Maps in other projections.
- “enable_tile_download”: No longer used; the app ignores it. Whether tiles of a map can be downloaded is the map’s own option Enable tile download in the app (on by default, see Online map tile downloader).
- “headers”: A list of headers sent with each map request. This can include the “User-Agent”, service specific API keys, etc.
- “unique_id”: A unique id for the map. The unique id must be unique in the Cartograph app.
- “folder_key”: The folder in which the map is located.
- “scripts” (optional, Cartograph Maps 4.1.5 and newer): JavaScript init and tile scripts and their parameters, see below.
Importing a file again replaces the maps with the same “unique_id” (see Importing online maps).
Scripts
A map can carry an init script, a tile script and parameters the user fills in on the map’s Script page. Each script is a string or an array of lines; “api” is the script interface version (currently 1). A file asking for a newer version is imported without its scripts.
"scripts": {
"api": 1,
"parameters": [
{ "key": "apiKey", "label": "API key", "type": "secret", "value": "" }
],
"init": [ "..." ],
"tile": [ "return tile.url + '&key=' + encodeURIComponent(params.apiKey);" ]
}
Parameter fields: “key” (required, the name in params), “value” (the default; leave secrets empty), “label”, “description” (help text under the field), “type” (“text”, “secret” for a masked field, or “choice” with “options”: strings or { "value", "label" }). Re-importing an updated file keeps the values the user entered.
What scripts can do, their arguments, return values and limits: Online map scripts. Before importing a file with scripts, the app asks the user for confirmation.