Vector maps guide
A practical guide with examples: a map on your page with MapLibre or Mapbox, map styles and label languages, your own layers on the map, 3D buildings, TileJSON and the data version, and the layer contract.
https://api.elemroot.com: not pump.elemroot.com,
where the geo services are.
- Authentication
- Quickstart: a map on a page (MapLibre GL JS)
- Map styles
- Labels in seven languages
- Mapbox GL JS and mobile SDKs
- Hybrid: orthophoto with roads and names
- Your own layers on the map
- 3D buildings
- TileJSON and your own style
- Data version
- Layers, contract and changelog
- Using tiles directly
- Sprites and fonts
- QGIS and other desktop clients
- Parameters
- When to use what
- Caching and CORS
- Error handling
Authentication
Style, sprite, TileJSON and tile requests require an API key passed as the query
parameter key; query string only (the key cannot be sent
in a header or cookie; its position in the query does not matter). Fonts, the layer contract,
the changelog and /health require no key.
The key must carry the vector-map (tiles) service permission; the orthophoto in the
hybrid style also needs the orthophoto (raster) permission. The key may be bound to an
origin; then it only works from the allowed web page (the browser sends Origin/Referer).
Use of the services is subject to the terms of use.
...&key=docs_3d4e64fa1755d7299cb78bf6
docs_… key used in the examples is a public
demo key for trying things out; the same one as for the geo services
(it rotates regularly and is rate-limited). It does not give the orthophoto. For your own
application, request a personal key.
The key goes in the style URL only. The style server adds the same key to every Elemroot URL inside the style: TileJSON, tiles, sprite and the hybrid orthophoto. You do not need to configure the key separately in the map library.
Quickstart: a map on a page (MapLibre GL JS)
A complete minimal page: copy, replace the key and open it through a web server (for example python3 -m http.server).
Opened directly from a file, the map tiles do not load.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@6.11.2/dist/maplibre-gl.css">
<style> html, body, #map { margin: 0; height: 100%; } </style>
</head>
<body>
<div id="map"></div>
<script type="module">
import * as maplibregl from 'https://unpkg.com/maplibre-gl@6.11.2/dist/maplibre-gl.mjs';
const map = new maplibregl.Map({
container: 'map',
attributionControl: { compact: true },
style: 'https://api.elemroot.com/styles/v2/daylight/style.json?key=docs_3d4e64fa1755d7299cb78bf6&lang=en',
center: [24.75, 59.44], // [longitude, latitude]: Tallinn
zoom: 10,
// Rotate and tilt (right mouse button or Ctrl + drag)
// at an even speed across the whole map
aroundCenter: false,
rotateSpeed: 0.4,
pitchSpeed: -0.4
});
map.addControl(new maplibregl.NavigationControl());
</script>
</body>
</html>
That is all you need: the style itself points to the right tile, sprite and
font URLs, and the map credit (© Elemroot) comes from the style.
Working example: examples.elemroot.com/vector-map.
Map styles
The style URL contains the style id {style}:
https://api.elemroot.com/styles/v2/{style}/style.json?key=…
All styles use the same vector tiles, so switching the style
(map.setStyle(newUrl)) does not reload the tiles. Overview with pictures:
Map styles.
| Id | Name | Use |
|---|---|---|
daylight | Daylight | the main base map |
moonlight | Moonlight | the same content in dark colours |
hybrid | Hybrid | orthophoto with roads and names (see hybrid) |
heirloom | Heirloom | a style based on the style of the Elemroot raster map |
rounds | Rounds | a work map for service rounds and larger vehicles |
rounds_night | Rounds Night | the same work map in dark colours |
data_light | Data Light | a quiet background for your own data layers |
data_dark | Data Dark | the same in dark colours |
winter | Winter | a winter base map in light snowy colours |
christmas | Christmas | a dark holiday-season base map in Christmas colours |
Load the style from our URL, not as a copy from your own server: then style fixes and new data reach
the map on their own. You can adjust the style in code (map.setPaintProperty,
map.setLayoutProperty). The styles have no initial view: set center and zoom yourself.
Labels in seven languages
The language of place names is chosen with the lang parameter in the style URL:
et Estonian (default), en English, ru Russian,
lv Latvian, lt Lithuanian, fi Finnish,
de German. An unknown value gives the Estonian style.
style: 'https://api.elemroot.com/styles/v2/daylight/style.json?key=docs_3d4e64fa1755d7299cb78bf6&lang=en'
To switch the language, load the same style with another language: map.setStyle('…/style.json?key=…&lang=lv');
the tiles are not reloaded. If an object has no name in the chosen language, the local name is shown.
Street names, road numbers and house numbers are in their local form in every language.
Mapbox GL JS and mobile SDKs
Every style has a variant mapbox.json for the Mapbox libraries (same URL, different file name):
https://api.elemroot.com/styles/v2/{style}/mapbox.json?key=…&lang=…
The content is the same; in addition it has the layer slots (slot) bottom
(above land cover and buildings, below roads), middle (above roads and boundaries, below labels)
and top (on top of everything), for placing your own layer in the right spot.
<link rel="stylesheet" href="https://unpkg.com/mapbox-gl@3.33.0/dist/mapbox-gl.css">
<script src="https://unpkg.com/mapbox-gl@3.33.0/dist/mapbox-gl.js"></script>
<div id="map" style="height: 400px"></div>
<script>
mapboxgl.accessToken = 'YOUR_MAPBOX_TOKEN'; // the Mapbox library requires a Mapbox token
const map = new mapboxgl.Map({
container: 'map',
style: 'https://api.elemroot.com/styles/v2/daylight/mapbox.json?key=docs_3d4e64fa1755d7299cb78bf6&lang=en',
center: [24.75, 59.44],
zoom: 10
});
map.on('load', () => {
map.addSource('points', { type: 'geojson', data: {
type: 'Feature', geometry: { type: 'Point', coordinates: [24.75, 59.44] } } });
map.addLayer({ id: 'points', type: 'circle', source: 'points', slot: 'middle',
paint: { 'circle-radius': 8, 'circle-color': '#d9480f' } });
});
</script>
In mobile apps, pass the style URL as the style URI: Mapbox Maps SDK and Navigation SDK (iOS, Android)
use the mapbox.json URL, MapLibre Native (iOS, Android) the style.json URL.
Hybrid: orthophoto with roads and names
The style hybrid (Hybrid) shows the orthophoto with roads, boundaries and names. The
orthophoto covers Estonia, Latvia and Lithuania; its credit comes from the style and is shown below the map.
style: 'https://api.elemroot.com/styles/v2/hybrid/style.json?key=YOUR_KEY'
Besides the vector-map (tiles) permission, the key needs the orthophoto (raster)
permission. Without it the vector layer loads as usual, but the orthophoto tiles return 403
and a dark background is shown instead of the orthophoto. The demo key does not give the orthophoto.
Your own layers on the map
Every style has metadata["elemroot:before_id"]: the layer below which your own data fits.
Your layers then stay above roads and boundaries, while place names stay on top and readable.
map.on('load', () => {
const beforeId = map.getStyle().metadata['elemroot:before_id'];
map.addSource('my-areas', { type: 'geojson', data: '/my-areas.geojson' });
map.addLayer({
id: 'my-areas', type: 'fill', source: 'my-areas',
paint: { 'fill-color': '#d9480f', 'fill-opacity': 0.4 }
}, beforeId);
});
Read the layer id from the style, do not hard-code it: it may differ between styles. Switching the
style with setStyle removes your own layers; add them again after the switch.
Ready-made data layers on top of the map, such as cadastral parcels: Overlays.
3D buildings
The building layer building has the fields height (height of the top above ground,
in metres) and min_height (height of the bottom, for example on an overhanging building part;
absent means 0). Buildings are in the detail area from z13. The styles have ready-made 3D layers that are hidden by
default. Usually it is one layer, building-3d. The styles winter and christmas have
several 3D layers, marked in metadata with "elemroot:toggle": "building-3d". Switch them all
at once:
function set3D(map, on) {
const style = map.getStyle();
const show = (id, visible) => map.setLayoutProperty(id, 'visibility', visible ? 'visible' : 'none');
for (const layer of style.layers) {
const mark = layer.metadata && layer.metadata['elemroot:toggle'];
if (layer.id === 'building-3d' || mark === 'building-3d') show(layer.id, on);
}
// House numbers: on the roof in 3D, on the ground otherwise
const hn = style.metadata && style.metadata['elemroot:housenumber_3d'];
if (hn && hn.switch === 'app-visibility' && map.getLayer(hn.flat) && map.getLayer(hn.roof)) {
show(hn.flat, !on);
show(hn.roof, on);
}
}
set3D(map, true);
map.easeTo({ pitch: 60, zoom: 16 });
If the style metadata has the key elemroot:housenumber_3d, house numbers have two layers:
flat shows the numbers on the ground and roof at the height of the building roof. Only one of
them should be visible at a time. In a style without 3D layers the function does nothing. Call the function again after
changing the style (setStyle).
3D buildings with your own design:
map.addLayer({
id: 'buildings-3d', type: 'fill-extrusion',
source: 'elemroot', 'source-layer': 'building',
filter: ['all', ['!=', ['get', 'kind'], 'underground'], ['!', ['has', 'has_parts']]],
paint: {
'fill-extrusion-color': '#c8ccd1',
'fill-extrusion-height': ['coalesce', ['get', 'height'], 3],
'fill-extrusion-base': ['coalesce', ['get', 'min_height'], 0],
'fill-extrusion-opacity': 0.9
}
}, map.getStyle().metadata['elemroot:before_id']);
A building made of parts (has_parts) has its parts as separate objects (is_part), each
with its own height. The filter leaves out the whole outline so that the parts do not overlap.
Working example: 3D buildings.
Patterned 3D walls on iPhone and iPad
MapLibre GL JS sometimes draws patterned 3D buildings incorrectly on iPhone and iPad: light patches appear on the walls
while the map is rotated. Of the Elemroot styles, christmas has patterned 3D walls. Other styles are not
affected.
If you wish, you can use MapLibre GL JS 6.11.2 with this fixed:
maplibre-gl-6.11.2-elemroot.1.zip (0.3 MB). Unpack the archive, copy the four files in
dist to one folder on your server and load MapLibre from there:
<link rel="stylesheet" href="/maplibre/maplibre-gl.css">
<script type="module">
import * as maplibregl from '/maplibre/maplibre-gl.mjs';
// continue as in the quick start
</script>
Using it is optional: all Elemroot styles also work with standard MapLibre GL JS. The archive includes a guide, the MapLibre license and a script that applies the same change to the package installed from npm. This is not an official MapLibre release.
TileJSON and your own style
All styles use one source, elemroot. Its description (TileJSON 3.0.0) is at
/tiles/v2/elemroot-v2.json:
curl "https://api.elemroot.com/tiles/v2/elemroot-v2.json?key=docs_3d4e64fa1755d7299cb78bf6"
| Field | Content |
|---|---|
tiles | tile URL template with the data version and your key |
minzoom, maxzoom | 0 and 15 |
vector_layers | layers and their fields |
elemroot:data_version | data version (see data version) |
elemroot:languages | label languages |
elemroot:detail_bounds | bounds of the detail area (the Baltics and neighbouring areas) |
elemroot:contract_url, elemroot:changelog_url | layer contract and changelog (see contract) |
In your own style, refer to the source like this:
"sources": {
"elemroot": {
"type": "vector",
"url": "https://api.elemroot.com/tiles/v2/elemroot-v2.json?key=YOUR_KEY"
}
},
"glyphs": "https://api.elemroot.com/fonts/{fontstack}/{range}.pbf"
The source name elemroot is the same as in our styles, so you can copy their layers into your style.
When building your own style, keep the map credit © Elemroot (the TileJSON attribution).
Data version
Every data update gets a new data version (the TileJSON field elemroot:data_version). The tiles
have a separate URL for each data version and never change, so browsers and caches can keep them for a long
time. The style and elemroot-v2.json always point to the current data version: new data reaches
the map on its own.
| URL | Content |
|---|---|
/tiles/v2/elemroot-v2.json?key=… | current data version |
/tiles/v2/elemroot-v2/{version}.json?key=… | a specific data version |
/tiles/v2/elemroot-v2/{version}/{z}/{x}/{y}.mvt?key=… | tiles of that data version |
The server keeps the three latest data versions; URLs of an older version return 404.
A specific version URL suits a map that has to stay unchanged for a while. Otherwise use the
unversioned elemroot-v2.json URL.
Layers, contract and changelog
| Layer | Content | Zoom in the detail area | Zoom elsewhere |
|---|---|---|---|
water | Water areas: sea, lakes, river and canal areas | 0–15 | 0–11 |
waterway | Waterways as lines: rivers, streams, canals, ditches | 5–15 | 3–11 |
landcover | Land cover: forest, scrub, wetland, farmland and grassland, sand, rock, ice | 0–15 | 0–11 |
landuse | Land use: residential, industrial and commercial areas, cemeteries, parks etc. | 5–15 | 5–11 |
protected_area | Protected areas | 6–15 | 6–11 |
boundary | Country and administrative boundaries | 0–15 | 0–11 |
admin_area | Administrative areas: countries, in the Baltics also counties and municipalities | 0–15 | 0–11 |
place | Place names: countries, administrative units, settlements and districts | 0–15 | 0–11 |
natural_label | Natural names: seas, bays, islands, lakes etc. | 0–15 | 0–11 |
transport | Roads, cycle and footways, railways and ferry lines | 4–15 | 4–11 |
transport_label | Road names and road numbers | 6–15 | 6–11 |
building | Buildings (height, min_height) | 13–15 | – |
address | House numbers and farm and house names | 14–15 | – |
poi | Points of interest | 6–15 | 10–11 |
aeroway | Aerodromes, runways and taxiways | 9–15 | 10–11 |
aeroway_label | Aerodrome names | 6–15 | 6–11 |
structure | Structures: quays, piers, dams, towers etc. | 12–15 | – |
The detail area is the Baltics with neighbouring areas (elemroot:detail_bounds). The exact description
(layers, fields, types, allowed values and zooms) is in the layer contract; changes to the contract
(a new layer, field or value) are in the changelog. Both exist for each data version, need no key and
are in Estonian and English:
https://api.elemroot.com/tiles/v2/elemroot-v2/{version}/contract_vector_layers.json
https://api.elemroot.com/tiles/v2/elemroot-v2/{version}/changelog.json
The URLs for the current data version are in the TileJSON (elemroot:contract_url, elemroot:changelog_url).
Using tiles directly
A single tile is a gzip-compressed Mapbox Vector Tile (protobuf) in the XYZ scheme, Web Mercator (EPSG:3857). Usually the map library requests them itself; for a manual check:
curl -s --compressed -o tile.mvt -w "%{http_code} %{content_type}\n" \
"https://api.elemroot.com/tiles/v2/elemroot-v2/10/584/305.mvt?key=docs_3d4e64fa1755d7299cb78bf6"
The unversioned URL /tiles/v2/elemroot-v2/{z}/{x}/{y}.mvt returns the tile of the current data
version and suits clients that do not read TileJSON (for example QGIS). Map libraries use the URL with the data
version from the TileJSON.
The response content type is application/x-protobuf and the tile is always gzip-compressed
(Content-Encoding: gzip); map libraries decompress it themselves, when saving by hand use
--compressed. There is data for the whole world at z0–11 and in the detail area at z0–15; above z15 the
map library scales up the z15 tile. Outside the detail area the z12–15 tiles are empty. An empty tile returns
204 No Content: this is normal, not an error. An x/y value above
2z−1 wraps around (mod 2z); z above 15 returns 404.
Sprites and fonts
Every style has its own sprite (map symbols and patterns): /styles/v2/sprite/{style}.json and
.png, high resolution {style}@2x.json and @2x.png (with key).
The style refers to it itself.
To show place names the map library loads font files (glyph PBF) with the pattern
/fonts/{fontstack}/{range}.pbf (no key, ranges in steps of 256). Our styles use the fonts
Noto Sans, Noto Serif and Barlow Condensed.
curl -s -o glyphs.pbf "https://api.elemroot.com/fonts/Noto%20Sans%20Regular/0-255.pbf"
Exactly these fontstacks are available:
| Font | Fontstacks |
|---|---|
| Arial | Arial Bold · Arial Regular |
| Arial Unicode MS | Arial Unicode MS Regular |
| Barlow Condensed | Barlow Condensed Bold · Barlow Condensed Bold,Noto Sans Bold · Barlow Condensed Medium · Barlow Condensed Medium,Noto Sans Medium · Barlow Condensed Regular · Barlow Condensed Regular,Noto Sans Regular · Barlow Condensed SemiBold · Barlow Condensed SemiBold,Noto Sans SemiBold |
| Cambria | Cambria Bold Italic |
| Fira Sans | Fira Sans Bold · Fira Sans Italic · Fira Sans Medium · Fira Sans Regular · Fira Sans SemiBold |
| Fira Sans Condensed | Fira Sans Condensed Bold · Fira Sans Condensed Medium · Fira Sans Condensed Regular · Fira Sans Condensed SemiBold |
| IBM Plex Sans | IBM Plex Sans Bold · IBM Plex Sans Italic · IBM Plex Sans Medium · IBM Plex Sans Regular · IBM Plex Sans SemiBold |
| IBM Plex Sans Condensed | IBM Plex Sans Condensed Regular · IBM Plex Sans Condensed SemiBold |
| Inter | Inter Bold · Inter Medium · Inter Regular · Inter SemiBold |
| Merriweather | Merriweather Bold · Merriweather Italic · Merriweather Regular |
| Montserrat | Montserrat Bold · Montserrat Medium · Montserrat Regular · Montserrat SemiBold |
| Noto Sans | Noto Sans Bold · Noto Sans Bold Italic · Noto Sans Italic · Noto Sans Medium · Noto Sans Regular · Noto Sans SemiBold |
| Noto Sans Condensed | Noto Sans Condensed · Noto Sans Condensed Bold · Noto Sans Condensed Medium · Noto Sans Condensed Regular |
| Noto Serif | Noto Serif Bold · Noto Serif Bold Italic · Noto Serif Italic · Noto Serif Regular |
| Open Sans | Open Sans Bold · Open Sans Italic · Open Sans Regular · Open Sans Regular,Arial Unicode MS Regular · Open Sans Semibold · Open Sans SemiBold Italic |
| Overpass | Overpass Bold · Overpass Regular · Overpass SemiBold |
| PT Sans | PT Sans Bold · PT Sans Italic · PT Sans Regular |
| PT Sans Narrow | PT Sans Narrow Bold · PT Sans Narrow Regular |
| Roboto | Roboto Bold · Roboto Bold,Noto Sans Bold · Roboto Italic · Roboto Italic,Noto Sans Italic · Roboto Medium · Roboto Medium,Noto Sans Regular · Roboto Regular · Roboto Regular,Noto Sans Regular |
| Roboto Condensed | Roboto Condensed Bold · Roboto Condensed Italic · Roboto Condensed Regular |
| Source Sans 3 | Source Sans 3 Bold · Source Sans 3 Italic · Source Sans 3 Regular · Source Sans 3 Semibold |
| Ubuntu | Ubuntu Bold · Ubuntu Italic · Ubuntu Medium · Ubuntu Medium Italic · Ubuntu Regular · Ubuntu Regular Italic |
| Verdana | Verdana Bold · Verdana Bold Italic · Verdana Italic · Verdana Regular |
text-font value. A comma stack
(e.g. ["Barlow Condensed SemiBold", "Noto Sans SemiBold"]) works only if it is in the list:
the server does not compose fonts on the fly, any other combination returns 404
and the labels disappear from the map. Ranges come only in steps of 256 (0-255, 256-511 …).
QGIS and other desktop clients
QGIS (3.14+): Browser → Vector Tiles → New Generic Connection:
| Field | Value |
|---|---|
| URL | https://api.elemroot.com/tiles/v2/elemroot-v2/{z}/{x}/{y}.mvt?key=YOUR_KEY |
| Min/Max zoom | 0 / 15 |
| Style URL (optional) | https://api.elemroot.com/styles/v2/daylight/style.json?key=YOUR_KEY |
Parameters
* = required. The key key (query) is
required everywhere except fonts, the contract, the changelog and /health: see authentication.
Style: /styles/v2/{style}/style.json and mapbox.json
| Param | Meaning | Possible values / example | Default |
|---|---|---|---|
{style} * | Style id | daylight, moonlight, hybrid, heirloom, rounds, rounds_night, data_light, data_dark, winter, christmas; unknown → 404 | — |
lang | Label language | et, en, ru, lv, lt, fi, de; unknown → et | et |
Tiles: /tiles/v2/elemroot-v2/{version}/{z}/{x}/{y}.mvt
| Param | Meaning | Possible values / example | Default |
|---|---|---|---|
{version} | Data version (from the TileJSON); absent in the unversioned URL | one of the three latest; older → 404 | current |
{z} * | Zoom level | 0…15; higher → 404 | — |
{x} * | Tile column (XYZ) | 0…2^z−1 (larger wraps around) | — |
{y} * | Tile row (XYZ) | 0…2^z−1 (larger wraps around) | — |
Fonts: /fonts/{fontstack}/{range}.pbf
| Param | Meaning | Possible values / example | Default |
|---|---|---|---|
{fontstack} * | Fontstack: exactly one of the available ones (URL-encoded) | Noto Sans Regular, Barlow Condensed SemiBold,Noto Sans SemiBold …; any other combination → 404 | — |
{range} * | Unicode range in steps of 256 | 0-255, 256-511 … 65280-65535; any other split → 404 | — |
When to use what
Common tasks and the matching endpoint.
| Task | Combination | Why |
|---|---|---|
| A map on a page with minimal effort | ready-made style /styles/v2/daylight/style.json?key=… in MapLibre | tile, sprite and font URLs and the key come with the style |
| Another look or label language | another style id and lang in the URL, switch with setStyle | all styles use the same tiles |
| Your own data on the map | addLayer(layer, metadata['elemroot:before_id']) | place names stay on top |
| Mapbox GL JS or a Mapbox mobile SDK | /styles/v2/{style}/mapbox.json?key=… + Mapbox token | layer slots bottom, middle, top |
| Orthophoto with roads and names | style hybrid, key also with the raster permission | the orthophoto credit comes from the style |
| Your own design | TileJSON /tiles/v2/elemroot-v2.json?key=… as the style source.url + your own layers | layers and fields from vector_layers and the contract |
| QGIS or another desktop client | unversioned tile URL /tiles/v2/elemroot-v2/{z}/{x}/{y}.mvt | see QGIS |
| L-EST97 grid, ready-made images or a client without WebGL | raster maps | vector maps are EPSG:3857 and need WebGL |
raster permission on the key; without it only the orthophoto tiles return 403.
(3) text-font must be an available fontstack, otherwise the labels silently disappear.
(4) Read elemroot:before_id from the style; it may differ between styles.
(5) A specific data version URL works while it is among the three latest.
(6) Tiles are always gzip-compressed: use --compressed when saving by hand.
(7) 204 is not an error but an empty spot.
Caching and CORS
| Resource | Cache-Control |
|---|---|
| Tiles at a data version URL | public, max-age=31536000, immutable |
| Tiles at the unversioned URL | public, max-age=86400 (24 h) |
| Style, TileJSON, sprites | public, max-age=3600 (1 h) |
| Layer contract, changelog | public, max-age=31536000, immutable |
| Fonts | public, max-age=604800 (7 days) |
All responses come with the header Access-Control-Allow-Origin: *; the map can be put on any
web page. On tiles the header is added in response to the browser's Origin header (Vary: Origin);
in a browser it is always present, with curl without Origin the header does not show and that is not an error.
Error handling
| Code | Meaning |
|---|---|
403 | Wrong or missing key: body {"error":"invalid_api_key"}. The same response comes with an expired key, when the key lacks the vector-map (tiles) service permission, when an origin-bound key is used outside the allowed page, and on the hybrid orthophoto tiles when the key lacks the orthophoto (raster) permission |
204 | Empty tile (no data): normal |
404 | z above 15 (Tile not found, text); unknown data version or style; unknown path → JSON {"error":"not_found"}. Note: x/y out of range does not give 404 (see using tiles directly) |
429 | Too many requests (the demo key is rate-limited): Too Many Requests, HTML body |
403 (key missing or wrong) and whether the style URL contains
?key=….
Next
Examples in the gallery
- Simple vector map
- Map styles
- Basemap switcher: vector, raster and orthophoto
- World map in the Equal Earth projection (EPSG:8857)
- Controlling the map view
- Camera flight along a path
- Map label language
- 3D buildings
- Markers and popups
- Your data layer on the basemap
- Your 3D objects on the basemap
- Point density: heatmap and hexagons