docs.maps
Add the map
An India-first vector basemap for MapLibre on web, Android and iOS. Map data © OpenStreetMap contributors; India's outer boundary follows the Survey of India.
Live in three steps
Get a maps key
Create a public key with the maps scope. It works from any site until you lock it to allowed websites or an Android / iOS app—same QuantaRoute account as geocoding.
Paste the style URL
Point MapLibre at the style URL and attach your public maps key with transformRequest on every tile, sprite, and font request.
Ship for India
Default center and zoom open on India. Keep OpenStreetMap attribution visible and go live.
MapLibre GL JS. Add your site as an allowed origin on the key.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>QuantaRoute Maps</title>
<link rel="preconnect" href="https://maps.quantaroute.com" crossorigin>
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css">
<style>html, body, #map { height: 100%; margin: 0; }</style>
</head>
<body>
<div id="map" role="application" aria-label="Map of India"></div>
<script src="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>
<script type="module">
import { CompassControl, ZoomControl }
from 'https://maps.quantaroute.com/controls/v1/qr-controls.js';
const MAPS = 'https://maps.quantaroute.com';
const KEY = 'dp_your_key'; // public maps key; optional: lock it to this origin in the dashboard
function mapsUrl(url) {
const u = new URL(url, location.href);
if (u.origin === MAPS) u.searchParams.set('key', KEY);
return u.toString();
}
const map = new maplibregl.Map({
container: 'map',
style: mapsUrl(MAPS + '/styles/quantaroute.json'),
transformRequest: (url) => (url.startsWith(MAPS) ? { url: mapsUrl(url) } : { url }),
center: [76.43708, 22.66831],
zoom: 3.7,
minZoom: 3.2,
maxZoom: 21.9,
maxPitch: 85,
maxBounds: [[40, -8], [120, 52]]
});
// QuantaRoute zoom and pitch controls. Add bottom-up so compass sits above zoom.
map.addControl(new ZoomControl(), 'bottom-right');
map.addControl(new CompassControl({ maxPitch: 85 }), 'bottom-right');
</script>
</body>
</html>Styles
Three styles share the same tiles; switch any time with map.setStyle().
https://maps.quantaroute.com/styles/quantaroute.json // Default
https://maps.quantaroute.com/styles/quantaroute-light.json // Light
https://maps.quantaroute.com/styles/quantaroute-dark.json // DarkRecommended view
The options our own map uses.
center: [76.43708, 22.66831], zoom: 3.7, // opens on all of India
minZoom: 3.2, // the widest view
maxBounds: [[40, -8], [120, 52]], // tiles cover South Asia
maxZoom: 21.9,
maxPitch: 85, // tilt all the way to the horizonOn a narrow phone screen, open a little wider than zoom 3.7 (never below 3.2) so all of India fits. Keep the attribution control on: the data is OpenStreetMap's (ODbL).
Next
- 3D buildingsTurn on buildings in 3D with one layer or one button, and see how heights from OpenStreetMap are drawn.
- Map StudioGive the map your own colours, preview them live, and export code, a style file or a palette.
- API keysLock a key to your websites, or to your Android and iOS apps (package name or bundle id).