This is an example how to use for OpenLayers 3 using the ol-mapbox-style extension together with OpenMapTiles. Check out the code here.

Convert Mapbox GL style to OpenLayers style functions

The ol-mapbox-style converts the original Mapbox GL style specification into OpenLayers style functions. Thanks to this extension you are able to design maps for vector tiles using the existing tools and then switch to a different renderer.


Create a HTML page and include OpenLayers 3 and the standalone build of ol-mapbox-style omls.js. Since OpenLayers 3 draws on the browser canvas you also need to include the fonts used in the style in the page.

<!DOCTYPE html>
  <title>Klokantech Basic GL Style using ol-mapbox-style preview</title>
  <link rel="stylesheet" type="text/css" href="" />
  <link rel="stylesheet" href="">
    html, body {
      height: 100%;
      margin: 0;
    #map {
      width: 100%;
      height: 100%;
      background-color: #f8f4f0;
  <div id="map"></div>
  <script src=",Promise"></script>
  <script src=""></script>
  <script src="olms.js"></script>
  <script src="ol3.js"></script>


Create a new MVT source (url of ol.source.VectorTile) which points to the CDN of OpenMapTiles or your own tileserver.

We fetch our GL style specification (fetch function) and turn it into OpenLayers functions which we can apply to our vector tile layer.

var tilegrid = ol.tilegrid.createXYZ({tileSize: 512, maxZoom: 22});

var layer = new ol.layer.VectorTile({
  source: new ol.source.VectorTile({
    attributions: '© <a href="">OpenMapTiles</a> ' +
      '© <a href="">' +
      'OpenStreetMap contributors</a>',
    format: new ol.format.MVT(),
    tileGrid: tilegrid,
    tilePixelRatio: 8,
    url: '{z}/{x}/{y}.pbf?key=tXiQqN3lIgskyDErJCeY'

var view = new ol.View({
  center: [732602.1417165294, 5864590.06411005],
  resolution: 2445,
  maxResolution: 78271.51696402048

var map = new ol.Map({
  target: 'map',
  view: view

fetch('').then(function(response) {
  response.json().then(function(glStyle) {
    olms.applyStyle(layer, glStyle, 'openmaptiles').then(function() {
K is an open-source project from Klokan Technologies GmbH and OSM community
Share this page on