OGC API — Tiles in MapTiler Server
The OGC API — Tiles standard defines endpoints for creating Web APIs that support retrieving geospatial information as tiles. It is a successor to the WMTS standard.
MapTiler Server supports the following JSON endpoints:
-
Dataset landing page defines a dataset and provides access to the tiles.
- Tileset:
https://<YOUR_HOST>/api/tiles/{tilesId}/tiles
- Rasterized map:
https://<YOUR_HOST>/api/maps/{mapId}/tiles
- Tileset:
-
Dataset TileMatrixSets describes the dataset tile matrix sets according to the OGC Web API.
- Tileset:
https://<YOUR_HOST>/api/tiles/{tilesId}/tileMatrixSet
- Rasterized map:
https://<YOUR_HOST>/api/maps/{mapId}/tileMatrixSet
- Tileset:
-
Conformance Classes declares the conformance classes implemented within our API.
https://<YOUR_HOST>/api/ogc/conformance
The Dataset landing page can be used in software supporting the OGC API — Tiles specification (currently OpenLayers).
Getting started with OpenLayers
We’ve prepared an OpenLayers demo viewer for raster and vector tiles to showcase the capabilities. Implementing this in your web applications is straightforward, see the OpenLayers OGC Vector Tiles and OGC Raster Tiles examples.
-
Load the OpenLayers library in the
<head>
section and set the UTF-8 encoding. -
Add an element to be inflated by the OpenLayers into the HTML
<body>
.<div id="map" style="width: 640px; height: 480px;"></div>
- Get the URL of the dataset:
- Go to your MapTiler Server at http://localhost:3650/admin.
- To get a URL of a rasterized map, click Details next to the map. For a tileset, go to page Tiles and click Details next to the desired tileset.
- Find the OGC Tiles API section and copy the URL.
-
Add JavaScript code that will initialize the OpenLayers raster map.
- Check that the
target
matches theid
of the inflated HTML element. - In the
layers
array, there’s a raster layerTile
with theOGCMapTile
source. Point itsurl
to your map’s dataset. - Set the desired initial zoom level and map position in the
view
property.
- Check that the
-
To load a vector tileset, replace
Tile
withVectorTile
and add some basic styling. - Add a proper attribution.
Custom projections with OpenLayers
OpenLayers library includes definitions for EPSG:4326
and EPSG:3857
. Use proj4
to define any other projection. Here is an example for EPSG:5514
:
-
Load
proj4
library in the<head>
section. -
Define the projection before
ol.Map
initialization:-
The projection name (
projName
) is thecrs
URL:Look into the console for an error like this:
Error: Unsupported CRS: http://www.opengis.net/def/crs/EPSG/0/5514
Alternatively, look into the dataset definition for the
crs
property. -
The projection definition (
projDef
) can be obtained:Manually from epsg.io, e.g. from https://epsg.io/5514.proj4.
Dynamically using the fromEPSGCode method, e.g.
ol.proj.proj4.fromEPSGCode("EPSG:5514")
(not recommended).
-
-
Set the projection of the Non-Mercator OGCMapTile or OGCVectorTile source.
OpenLayers limitations
- OpenLayers doesn’t automatically read or set
tileGrid
from the tileset tile matrix sets description. - The view is not initialized from the OGC API — Tiles
centerPoint
property.
Getting started with QGIS
To use raster tiles in QGIS, you’ll need to create two more JSON files (endpoints). In this example, we will add a satellite map into QGIS.
-
Create a new local JSON file, e.g.
tilesets.json
. This endpoint declares a list of the tileset projections.Set the API URL to the desired tileset/map.
-
Create another file within the same folder, e.g.
landing.json
. This endpoint is a dataset landing page linking the previous endpoint. This file will be always the same. -
OGC API — Tiles is used to request tiled data from a web service, not directly load a static local file. You have to:
- Upload the JSON files on some web server. Ensure that
href
link fromlanding.json
totilesets.json
is correct. -
Start a local server to serve the JSON files. In Python:
- Open the terminal and go to the folder containing the JSON files.
- Run:
python3 -m http.server
- The URL will be:
http://localhost:8000/landing.json
- Upload the JSON files on some web server. Ensure that
-
Load the dataset landing page endpoint in QGIS.
- Go to menu Layer > Add Layer > Add Raster Layer (Ctrl+Shift+R).
- As the Source Type, select
OGC API
. - As Source, enter the
landing.json
URL.
QGIS limitations
- OGC API — Tiles standard works only with Windows and QGIS 3.38 (GDAL 3.9).
- Only raster tiles are supported.
- QGIS doesn’t support reading tiles directly from the dataset landing page. QGIS can only work with raster tilesets and raster collections.
It’s important to note that GDAL/QGIS implements the draft of the OGC API — Tiles standard and the implementation is likely to change.
Supporting QGIS is on our roadmap, and we plan to expand the compatibility.