docs.maps.3d
3D buildings
The QuantaRoute basemap can draw buildings in 3D from the heights in OpenStreetMap. It is opt-in: every style ships flat, and you turn 3D on with one layer or one button.
height or building:levels tag. The rest are drawn 4.125 m tall, so the mapped buildings rise above them.Turn it on
Every QuantaRoute style has a hidden layer called building-3d.
// After the map's style has loaded (key on every request: see the snippet on /maps)
map.setLayoutProperty('building-3d', 'visibility', 'visible');
map.easeTo({ pitch: 55, zoom: 16 }); // buildings start at zoom 15; tilt the map to see their heightOr add the button our live map uses:
import { BuildingsControl, CompassControl } from 'https://maps.quantaroute.com/controls/v1/qr-controls.js';
map.addControl(new CompassControl({ maxPitch: 85 }), 'bottom-right'); // tilt up to the horizon
map.addControl(new BuildingsControl(), 'bottom-right');
// Options: { on: false, pitch: 55, zoom: 16 }. It keeps 3D on when you switch styles,
// and fires 'change' with { on } when someone presses it.Requests to maps.quantaroute.com need your public key with the Maps product; the Maps page has the full setup with transformRequest. No other tiles are needed: the heights come with the buildings.
Where the heights come from
From OpenStreetMap tags on each building, refreshed with the weekly map build.
| In OpenStreetMap | Drawn as |
|---|---|
| A height tag (height or building:height) | That height |
| No height, but building:levels | Levels × 3.66 m |
| Neither tag | 4.125 m, about one and a half storeys (National Building Code) |
| A height of 0 or less, or above 500 m (a typo: the tallest building in India is about 300 m) | 4.125 m |
| min_height or building:min_level (an upper part of a building) | Drawn from that height up |
| A base at or above the top (for example building:min_level=33 with no building:levels) | The base is ignored: the building stands on the ground |
| An outline whose parts are mapped separately | Only the parts are drawn, so nothing is drawn twice |
Wrong or illogical values are cleaned when the map is drawn, not removed, so every building still shows.
Your colours
The palette's building colour also colours the 3D buildings, shaded by height. Try it in Map Studio with the cube button on the map, then copy the code.
import { recolour } from 'https://maps.quantaroute.com/controls/v1/qr-palette.js';
const base = await (await fetch(mapsUrl('https://maps.quantaroute.com/styles/quantaroute.json'))).json();
map.setStyle(recolour(base, { building: '#d9cbb6' })); // 3D buildings take the building colour
map.once('styledata', () => map.setLayoutProperty('building-3d', 'visibility', 'visible'));Limits
- Buildings have flat tops. Roof shapes (OpenStreetMap roof:shape) are not drawn yet.
- 3D starts at zoom 15. Tiles are built to zoom 14 and stretched beyond, so buildings stay sharp up close.
- 3D needs a tilted map; at pitch 0 the buildings look like the flat footprints. Allow up to
maxPitch: 85for a view towards the horizon: the styles draw a sky there. - On older phones, many buildings at once can slow the map down. Keep 3D opt-in, as the button does.
Improve the data
Heights come from OpenStreetMap contributors. Adding building:levels (the number of floors above ground) or height to a building on openstreetmap.org shows up on this map after the next weekly build.