Use MapLibre GL JS to combine our OpenStreetMap vector tiles with aerial imagery of Düsseldorf from the Geobasis NRW WMS.
The map opens at zoom level 15 in central Düsseldorf. Your browser draws the roads and labels from our vector tiles at the screen’s resolution.
Use layers.roads,labels in the style URL to show both categories. To display just the labels over the imagery, replace it with layers.labels.
MapLibre requests one JPEG per tile from the Geobasis NRW WMS. In each GetMap request, it replaces {bbox-epsg-3857} with the tile’s bounds in Web Mercator (EPSG:3857).
The example requests 256 × 256 pixels per image. When window.devicePixelRatio is greater than 1, it requests 512 × 512 pixels for the same area.
Pass omniscale:below-roads as the second argument to map.addLayer(). This places the aerial imagery beneath the roads and labels.
Replace your-api-key with your public vector API key.
Save the code as an HTML file and serve it from the domain registered for that key.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@6.17.0/dist/maplibre-gl.css" />
<script type="module">
import * as maplibregl from 'https://unpkg.com/maplibre-gl@6.17.0/dist/maplibre-gl.mjs';
const map = new maplibregl.Map({
container: 'map',
style: 'https://maps.omniscale.net/v2/your-api-key/style.default/layers.roads,labels/style.json',
center: [6.773, 51.2297],
zoom: 15,
minZoom: 12,
maxZoom: 20,
maxBounds: [[6.4, 50.85], [7.68, 51.54]],
attributionControl: {compact: false},
});
map.addControl(new maplibregl.NavigationControl());
map.once('style.load', () => {
const imageSize = window.devicePixelRatio > 1 ? 512 : 256;
const wms = 'https://www.wms.nrw.de/geobasis/wms_nw_dop'
+ '?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=nw_dop_rgb&STYLES='
+ '&FORMAT=image/jpeg&SRS=EPSG:3857&BBOX={bbox-epsg-3857}'
+ `&WIDTH=${imageSize}&HEIGHT=${imageSize}`;
map.addSource('nrw-aerial', {
type: 'raster',
tiles: [wms],
tileSize: 256,
attribution: '<a href="https://www.bezreg-koeln.nrw.de/geobasis-nrw">Geobasis NRW</a>',
});
map.addLayer({
id: 'aerial',
type: 'raster',
source: 'nrw-aerial',
}, 'omniscale:below-roads');
});
</script>
</head>
<body>
<div id='map' style='height: 400px; width: 400px;'></div>
</body>
</html>