| description | In Mergin Maps mobile app, you can use online and offline background maps. See how to use raster and vector tiles and how to generate tiles for offline use. |
|---|
[[toc]]
When surveying in the field, it is essential to have appropriate background maps. There are several sources of background maps you can use in your QGIS project. Here, we will cover two types of background maps for online and offline use in : raster and vector tiles.
Online maps need internet connection to be displayed during the field survey and can use up a lot of mobile data, especially if you are using online raster maps.
Some background maps can be protected with an API key, a token or other kind of authorisation. When packaging the project, the packages DB entries used in these layers in the qgis_cfg.xml file and the can display them correctly.
:::warning Terms and conditions of background maps Keep in mind that background maps services and data sources come with their own terms of use.
Although we show how to add online and offline background maps to your projects, it is your responsibility to comply with any terms and conditions of the services of your choice. :::
Raster tiles are ideal for aerial imagery or terrain visualisations. They can be large in size and can appear pixelated when zoomed in.
QGIS comes by default with the . When adding a cartographic basemap, ensure you set the tile size correctly, so that the texts and labels are readable on mobile devices with high resolution display.
::: warning Online raster maps can use up a lot of mobile data during the field survey. :::
You can also add other sources of XYZ tiles to your QGIS.
To add Bing aerial imagery to your QGIS project:
-
In QGIS, navigate to the XYZ Tiles in the Browser panel
-
Set the parameters of the XYZ connection:
Now, the XYZ Tiles in the Browser panel should contain the Bing aerial imagery. Double click on it to add it to your project and zoom to your area of interest.

::: tip When using XYZ tiles that contain labels, ensure to set the tile resolution to Standard in the connection settings. This will ensure the fonts are readable on the high resolution screens (the majority of the recent smartphones comes with high DPI screens). :::
QGIS also offers a to generate raster tiles for offline use.
Make sure that you:
- added the Bing aerial imagery to the QGIS project
- zoomed to your area of interest
To generate an offline copy of the aerial imagery from your map view extent:
-
In QGIS, select Processing > Toolbox from the main menu. The Processing panel will appear on the right side of the QGIS window.
-
In the search section on the top of the Processing panel, type xyz to display relevant tools.
-
In Raster tools, double-click on Generate XYZ tiles (MBTiles)

-
Set the parameters of Generate XYZ tiles (MBTiles) tool:
- Extent: click on the right-side drop-down menu and select Use Map Canvas Extent
- Minimum zoom: 10
- Maximum zoom: 15
- Output file (for MBTiles): click on the right side drop-down menu and select Save to file. Browse to the folder where you want to save the MBTiles and name the file.
Here:
offline_aerial_photo.mbtiles - Click Run

:::warning Depending on the size of your study area and the zoom level, the output file can be very large. See how to work with large files in . :::
Vector tiles are a better alternative for cartographic maps as background data. They are smaller in size, have flexible styling and your maps will not be pixelated even when zoomed in.
There are several online services you can use in your projects, some of them are mentioned below.
When creating a new project from scratch, the default background map uses vector tile service. Other online vector tile services can be added to the project in QGIS, but keep in mind they come with their own terms of use.
To add a vector tile service:
-
In QGIS, navigate to the Vector Tiles in the Browser panel
-
Right-click on Vector Tiles and select New Generic Connection
-
Set the parameters of the Vector Tiles connection and press OK.
For vector tile service, the parameters are as follows:
- Name: OpenMapTiles (OSM)
- Style URL:
https://tiles.merginmaps.com/styles/default.json - Source URL:
https://tiles.merginmaps.com/data/default/{z}/{x}/{y}.pbf - Min. Zoom Level: 0
- Max. Zoom Level: 14
:::warning Usage details
Note that vector tile service can be used by users only .
Using the service is conditioned by the attribution:
© OpenMapTiles © OpenStreetMap contributors
:::
Since QGIS 3.32, the easy-to-use Download vector tiles algorithm is present in the Processing toolbox in QGIS. With , it can be used also in older QGIS version (3.16+) and is readily available from the Layers panel.
There are also other ways how to get offline vector tiles, such as using OpenMapTiles and Docker: ::: details Generate vector tiles using OpenMapTiles and Docker (Advanced) In the example below, we walk through steps to generate a vector tile using OpenMapTiles for Limpopo.
Note that instructions below require familiarity with the terminal. In addition, your operating system should support docker.
- Clone the OpenMapTiles repository:
git clone git@github.com:openmaptiles/openmaptiles.git - Download osm.pbf file for the country or region where your area falls in from here.
- Search for your area of interest and find the OSM relation ID (from here using method described or alternatively download it if available).
- Clip the osm.pbf downloaded in step 2 using the poly downloaded in step 3:
osmconvert south-africa.osm.pbf -B=limpopo.poly --complete-ways --complete-multipolygons -o=my.osm.pbf - Place my.osm.pbf under openmaptiles/data/
- Run
./quickstart.sh myfrom openmaptiles/ folder (where you cloned your repository): this will generate the tiles with the default settings (i.e. low zoom level of max=7) - Edit openmaptiles/data/my.dc-config.yml and change the Max_Zoom to 14
- Re-run
./quickstart.sh my - The above process should produce an MBTiles for your clipped OSM file
- You can load the file and style it using one of the :::
Vector tiles for offline use can be downloaded easily using .
-
Open your project in QGIS.
-
In the Layers panel, right-click on the vector tile layer and choose the Make available offline... option

-
Download Vector Tiles dialog opens. Set the parameters as needed:
- Extent should be defined by your area of interest. You may calculate it from your survey layer, use the current map canvas extent (after zooming in), or other options that are provided.
- Maximum zoom level to download defines the detail that will be visible on the offline map. For more information about zoom levels, see, for instance OpenStreetMap wiki.
- Tile limit is the maximum number of tiles that you want to download.
- Output will be saved as a MBTiles file. Click on the right side drop-down menu, select Save to file, browse to the folder where you want to save the MBTiles and name the file.
MBTiles can be stored in your project folder and synchronised to along with your project. If you find it impractical to synchronise them or if you want to use the same file in multiple projects, follow the steps on How to work with large files in .
-
Click Run. After the vector tiles are generated and downloaded successfully, the MBTiles file will be added to the Layers panel. You may close the algorithm dialog window.
-
Save and synchronise the project.
::: tip Before taking your offline tiles to the field, we recommend checking in that they have sufficient extent and zoom level. :::
Raster and vector tiles generated for offline use can be relatively large files, especially when using high resolution data or a large area of interest. It may be impractical to synchronise these large files through or to have duplicate copies if they are used in multiple projects.
:::tip If you do not need to use your background maps offline, consider creating a WMS or WMTS server for online use. :::
QGIS uses relative paths to load the data. If your project refers to files located in another folder, this project can be loaded just fine on another computer or in - if the folder with the files can be found in its expected location. Note that multiple projects can refer to the same files.
-
On your computer, create a folder that will contain the large datasets (here:
_rasters). It should be located in the same directory as your projects.
-
Open your project in QGIS. Load the files from the
_rastersfolder to the project. Save and sync. -
Connect your mobile device to the computer and copy the
_rastersfolder to the app's project folder- on Android, follow the steps described in Manual data transfer (Android)
- on iOS, follow the steps described in Manual data transfer (iOS)
-
Use the project in the as usual.
:::warning These files are not synchronised Files that are not located directly in the project folder are not synchronised. This saves your storage on . However, if you want to update or modify these files, you have to connect the mobile device to your computer and do it manually. :::






