OGC API — Tiles
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 Cloud supports the following JSON endpoints:
-
Dataset landing page defines a dataset and provides access to the tiles.
- Tileset:
https://api.maptiler.com/tiles/{tilesId}/tiles
- Rasterized map:
https://api.maptiler.com/maps/{mapId}/tiles
- Tileset:
-
Dataset TileMatrixSets describes the dataset tile matrix sets according to the OGC Web API.
- Tileset:
https://api.maptiler.com/tiles/{tilesId}/tileMatrixSet
- Rasterized map:
https://api.maptiler.com/maps/{mapId}/tileMatrixSet
- Tileset:
-
Conformance Classes declares the conformance classes implemented within our API.
https://api.maptiler.com/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 your API key and the dataset landing page URL of a tileset or a rasterized map at cloud.maptiler.com.
-
Add JavaScript code that will initialize the OpenLayers raster map.
- The
target
must match theid
of the inflated HTML element. - Add a new raster layer (
Tile
) into thelayers
array with theOGCMapTile
source. - Set the initial zoom level and map position in the
view
property.
- 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, including your API key.
-
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.
Related guides
- Automatically created API key
- Check if MapLibre GL JS is supported
- Coordinates API
- Dataset upload - formats and limits
- Difference between 256x256, 512x512, and HiDPI/Retina rasterized tiles
- Disputed borders on your maps
- Exported Tiles Multiplier
- Generalization in maps
- How are the tile requests cached in web browser?
- How MapTiler map tiles are Generated and Delivered