Semi-Transparent Layer

Example of a map with a semi-transparent layer.

This example will display a tiled MaxBox layer semi-transparently over an OSM background.

<!DOCTYPE html>
<html>
  <head>
    <title>Semi-Transparent Layer</title>
    <link rel="stylesheet" href="https://openlayers.org/en/v5.3.0/css/ol.css" type="text/css">
    <!-- The line below is only needed for old environments like Internet Explorer and Android 4.x -->
    <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=requestAnimationFrame,Element.prototype.classList,URL"></script>

  </head>
  <body>
    <div id="map" class="map"></div>
    <script>
      import Map from 'ol/Map.js';
      import View from 'ol/View.js';
      import TileLayer from 'ol/layer/Tile.js';
      import {fromLonLat} from 'ol/proj.js';
      import OSM from 'ol/source/OSM.js';
      import TileJSON from 'ol/source/TileJSON.js';


      var map = new Map({
        layers: [
          new TileLayer({
            source: new OSM()
          }),
          new TileLayer({
            source: new TileJSON({
              url: 'https://api.tiles.mapbox.com/v3/mapbox.va-quake-aug.json?secure',
              crossOrigin: 'anonymous',
              // this layer has transparency, so do not fade tiles:
              transition: 0
            })
          })
        ],
        target: 'map',
        view: new View({
          center: fromLonLat([-77.93255, 37.9555]),
          zoom: 7
        })
      });
    </script>
  </body>
</html>