Choose which OpenStreetMap features appear on the map and switch between color and grayscale.
You can show or hide each layer separately. For example, hide the buildings and turn on house numbers and points of interest.
Omniscale supplies the OpenStreetMap layers in this example. Our maps cover the whole world and are available as raster tiles, vector tiles or via WMS.
To run this example in your own application, start a free 14-day trial and create an API key.
More examples Explore features of our map services
If you select only roads and labels, OpenLayers sends LAYERS=roads,labels. Switching from color to grayscale changes STYLES=default to STYLES=grayscale.
The example calls updateParams() on the ImageWMS source to request one image for the visible map area. If you turn off all the layers, OpenLayers hides the image and sends no map request.
Replace your-api-key with your public raster 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">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.layer-example {
display: grid;
gap: 1rem;
}
.layer-example #map {
min-width: 0;
max-width: 1150px;
min-height: 400px;
}
#map-options {
--button-color: #6c757d;
font-family: Raleway, Helvetica, Arial, sans-serif;
}
#map-options fieldset {
display: flex;
flex-wrap: wrap;
gap: .5rem;
min-width: 0;
margin: 0;
padding: 0;
border: 0;
}
#map-options fieldset + fieldset {
margin-top: .75rem;
}
#map-options legend {
float: none;
margin: 0 0 .25rem;
padding: 0;
font-size: 1.125rem;
font-weight: bold;
}
#map-options input {
position: absolute;
width: 1px;
height: 1px;
clip-path: inset(50%);
}
#map-options label {
padding: .25rem .5rem;
border: 1px solid var(--button-color);
border-radius: .25rem;
color: var(--button-color);
font-size: .875rem;
line-height: 1.5;
text-align: center;
cursor: pointer;
}
#map-options input:checked + label {
background-color: var(--button-color);
color: white;
}
#map-options label:hover {
border-color: #343a40;
}
#map-options input:focus-visible + label {
outline: 2px solid #495057;
outline-offset: 2px;
}
@media (min-width: 768px) {
.layer-example {
grid-template-columns: 12rem minmax(0, 1fr);
}
#map-options fieldset {
flex-direction: column;
}
}
</style>
<script src="https://cdn.jsdelivr.net/npm/ol@v10.3.1/dist/ol.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@v10.3.1/ol.css">
<script>
function initMap() {
const form = document.getElementById('map-options');
const pixelRatio = Math.min(2, Math.max(1, window.devicePixelRatio || 1));
const source = new ol.source.ImageWMS({
url: 'https://maps.omniscale.net/v2/your-api-key/attribution.false/map',
params: {
VERSION: '1.1.1',
FORMAT: 'image/png',
TRANSPARENT: true,
hq: pixelRatio > 1,
},
ratio: 1,
serverType: 'qgis', // Send the WMS DPI parameter.
attributions: '© 2026 <a href="https://maps.omniscale.com/">Omniscale</a> · ' +
"Map data:" + ' <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> (ODbL)',
});
const layer = new ol.layer.Image({source});
function updateLayers() {
const options = new FormData(form);
const layers = options.getAll('layer');
layer.setVisible(layers.length > 0);
if (layers.length) {
source.updateParams({LAYERS: layers.join(','), STYLES: options.get('style')});
}
}
form.addEventListener('change', updateLayers);
updateLayers();
new ol.Map({
target: 'map',
pixelRatio,
layers: [layer],
controls: ol.control.defaults.defaults({attributionOptions: {collapsible: false}}),
view: new ol.View({
center: ol.proj.fromLonLat([8.21544, 53.13715]),
zoom: 18,
minZoom: 6,
maxZoom: 20,
}),
});
}
</script>
</head>
<body onload='initMap()'>
<div class="layer-example">
<form id="map-options">
<fieldset>
<legend>Map layers</legend>
<input type="checkbox" id="layer-world" name="layer" value="world" checked>
<label for="layer-world">Land and water</label><input type="checkbox" id="layer-landusages" name="layer" value="landusages" checked>
<label for="layer-landusages">Land use</label><input type="checkbox" id="layer-admin" name="layer" value="admin" checked>
<label for="layer-admin">Administrative boundaries</label><input type="checkbox" id="layer-roads" name="layer" value="roads" checked>
<label for="layer-roads">Roads</label><input type="checkbox" id="layer-buildings" name="layer" value="buildings" checked>
<label for="layer-buildings">Buildings</label><input type="checkbox" id="layer-labels" name="layer" value="labels" checked>
<label for="layer-labels">Labels</label><input type="checkbox" id="layer-housenumbers" name="layer" value="housenumbers">
<label for="layer-housenumbers">House numbers</label><input type="checkbox" id="layer-pois" name="layer" value="pois">
<label for="layer-pois">Points of interest</label>
</fieldset>
<fieldset>
<legend>Map style</legend>
<input type="radio" id="style-default" name="style" value="default" checked>
<label for="style-default">Color</label><input type="radio" id="style-grayscale" name="style" value="grayscale">
<label for="style-grayscale">Grayscale</label>
</fieldset>
</form>
<div id="map"></div>
</div>
</body>
</html>