Table of Contents


Preparing offline maps for Mapeo Desktop and Mapeo Mobile from Mapbox Studio

This workflow is for downloading map styles and tiles from Mapbox Studio to get these working offline in Mapeo Desktop Observations and Mapeo Mobile.

mapbox-style-downloader is a Node script created by Digital Democracy which can download Mapbox styles, sprites, glyphs (fonts) and tiles for offline usage.

<aside> ❗ Note: Mapbox is currently requesting that all third parties using this script ask for permission from the community team before using. If you want to use this script, email [email protected] before proceeding.

Also, be careful: This has the capability to send Mapbox a lot of requests. Try not to get your token throttled beyond the free tier, resulting in a need to pay for your tile requests! Make sure you pick reasonable bounding boxes and zoom levels, because the data can get very large, very fast.

Refer to the pricing schema here; currently, maximum tile requests within the free tier to the Vector Tiles API is 200,000, and Raster Tiles API is 750,000.

</aside>

Install / setup Node and mapbox-style-downloader

  1. Install Node (default version 12) on your computer.
  2. Install the Node package mapbox-style-downloader by running npm install --global mapbox-style-downloader.

Download map style and tiles from Mapbox.com

  1. Design a map on mapbox.com using Studio. Save your changes by Publishing the map.

    1. Note that it is possible to add raster imagery (such as satellite images) to Mapbox Studio i.e. in GeoTIFF format, and download it using the mapbox-style-downloader script.

    2. Before publishing the map, you need to set compatibility for Maps SDK for Android to 5.2.0+ and Mapbox GL JS to 1.4.0+.

      https://s3-us-west-2.amazonaws.com/secure.notion-static.com/7e98138b-0889-49e1-a80d-b3ef97001009/Untitled.png

  2. Get your Mapbox map link and style token. On your Mapbox.com map, click on Share... and copy down the Style URL and Access token.

  3. Get your bounding box for the tiles you will download, and calculate an estimate of the number of raster and vector tiles to be generated in advance. You can use the Mapbox tool for that: https://docs.mapbox.com/playground/offline-estimator/. Note that the maximum monthly tile requests to the Vector Tiles API is 200,000, and Raster Tiles API is 750,000.

    1. You can also use http://boundingbox.klokantech.com/, or QGIS to get coordinates.
  4. Next, in the terminal navigate to a directory where you want to create the tiles.

    Tip: you can enter cd and then drag the directory from Finder or Explorer to the terminal to autogenerate the path.

  5. Run the following line of code. You can use this script below as a model, and change the bits in bold as follows.

    mapbox-style download **-z 0 -Z 15** --bounds '**-123.105109,49.26913,-123.066898,49.290328**' **mapbox://styles/mapboxuser/dsfjl32r2ljflk23** --token='**pk.eysdjflsd2390jklsdf2sj490sjd92.sdjdildj29s**' -o '**curacao**' **-u 0 -U 9215 --asar**
    
  6. When successfully completed, the script will have generated a directory containing the following (unless you included a parameter to only download one of these):

    1. A style.json file with your tileset definitions, and map canvas.
    2. A tiles directory containing your map vector and raster tiles.
    3. A glyphs directory containing your font glyphs.
    4. A sprites directory containing graphics for icons used on your map.