Hosted map styles for MapLibre GL JS
The hosted style.json URL is the main entry point for our vector map service.
The style tells your map library how to draw the map and where to request tiles from our latest Mapbox Vector Tile (MVT) dataset.
https://maps.omniscale.net/v2/{api-key}/style.json
Replace {api-key} with a vector API key registered for your website’s domain.
You can create one in the Vector tiles tab in the customer area.
We recommend MapLibre GL JS, the renderer we officially support for our vector styles. The current styles require version 5.22.0 or later.
Here is how to load the map in MapLibre GL JS. Pass the hosted style URL as the style option.
const map = new maplibregl.Map({
container: 'map',
style: 'https://maps.omniscale.net/v2/your-api-key/style.json',
center: [8.22, 53.14],
zoom: 13
});
Keep the attribution control visible to display the credits supplied by the style. See the complete MapLibre GL JS example.
If your application requires OpenLayers, use the ol-mapbox-style converter to load the same style URL. MapLibre GL JS generally renders vector maps faster, and OpenLayers places labels differently.
You can select the map style with the style path segment.
Use style.default for the standard color map or style.grayscale for grayscale.
If you omit this segment, the map uses the standard color style.
https://maps.omniscale.net/v2/{api-key}/style.default/style.json
https://maps.omniscale.net/v2/{api-key}/style.grayscale/style.json
With vector tiles, you can choose which layers your map draws. In our vector styles, roads alone use separate layers for outlines and fills, with additional layers for bridges and tunnels. If you selected these layers individually, you would have to track their internal names and update your application whenever we added or renamed a road layer.
To give you a stable way to select map content, we group these layers into the same categories as the raster API.
The roads category lets you show or hide all the road layers together, even when we change how the style draws them.
You can set the initial selection in the style URL and change it after the map loads using MapLibre global state.
Use the layers path segment to select categories. It can come before or after style.
For the default map, omit this segment or use layers.osm.
+ to add that category or - to hide it.Roads and labels only https://maps.omniscale.net/v2/{api-key}/layers.roads,labels/style.json Grayscale map without labels or house numbers https://maps.omniscale.net/v2/{api-key}/style.grayscale/layers.-labels,-housenumbers/style.json Default map with points of interest https://maps.omniscale.net/v2/{api-key}/layers.+pois/style.json
| Layer | Enabled by default | Map content |
|---|---|---|
world | Yes | Land and water background |
landusages | Yes | Land use, including forests, parks, and built-up areas |
admin | Yes | Administrative boundaries |
roads | Yes | Roads |
buildings | Yes | Building footprints |
labels | Yes | Map labels, including place and street names |
housenumbers | Yes | House numbers |
pois | No | Points of interest, including shops, hospitals, and parking lots |
All selections use the same vector tiles. Hiding a category changes what the map draws, and its features remain in the downloaded tiles.
Use MapLibre global state to show or hide a category while someone is using the map.
Call map.setGlobalStateProperty with omniscale: followed by the category name.
Set the value to true to show the category or false to hide it.
This checkbox starts with the style’s current setting. Selecting or clearing it shows or hides points of interest without reloading the map.
<label><input type="checkbox" id="show-pois" disabled> Show points of interest</label>
map.on('load', () => {
const checkbox = document.getElementById('show-pois');
checkbox.checked = map.getGlobalState()['omniscale:pois'];
checkbox.disabled = false;
checkbox.addEventListener('change', () => {
map.setGlobalStateProperty('omniscale:pois', checkbox.checked);
});
});
Labels, house numbers, and points of interest each have their own switch.
Pass null to restore a category’s initial setting from the style URL.
If your application replaces the style, reapply the user’s choices after the new style loads.
For MapLibre GL JS 6.x, use 6.17.0 or later when switching layers at high zoom.
In earlier 6.x releases, set zoomLevelsToOverscale: undefined in the map constructor so previously hidden layers can appear above the dataset’s maximum zoom.
When you add your own data to the map, you can choose which parts of the basemap appear above or below it. For example, you might draw a route line below the map labels so street names stay readable, and place its stops above the labels. Our styles provide named positions, called anchors, for placing your own layers.
Pass the anchor name as the beforeId argument to map.addLayer. MapLibre draws your layer immediately before that anchor.
The omniscale:below-{category} anchor comes before the category’s first layer.
The omniscale:above-{category} anchor comes after its last layer, so inserting there draws your layer above the category.
The labels anchors span map labels, house numbers, and points of interest. This example uses a GeoJSON file containing a LineString for the route and Point features for its stops.
map.on('load', () => {
map.addSource('route', {type: 'geojson', data: '/data/route.geojson'});
map.addLayer({
id: 'route-line',
type: 'line',
source: 'route',
filter: ['==', ['geometry-type'], 'LineString'],
paint: {'line-color': '#2166ac', 'line-width': 4}
}, 'omniscale:below-labels');
map.addLayer({
id: 'route-stops',
type: 'circle',
source: 'route',
filter: ['==', ['geometry-type'], 'Point'],
paint: {'circle-color': '#2166ac', 'circle-radius': 6}
}, 'omniscale:above-labels');
});
Anchors keep their positions when you hide or show a category. Categories can overlap in drawing order, so the range between two anchors can include other map content. Symbol layers still follow MapLibre’s label collision rules.