Example of a WMTS source created from a WMTS capabilities document.
This example shows how to create the configuration for accessing a WMTS from a GetCapabilities response.. The WMTS example shows how to create the configuration manually.
<!DOCTYPE html> <html> <head> <title>WMTS Layer from capabilities example</title> <script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link rel="stylesheet" href="http://openlayers.org/en/3.8.1/css/ol.css" type="text/css"> <script src="http://openlayers.org/en/3.8.1/build/ol.js"></script> </head> <body> <div class="container-fluid"> <div class="row-fluid"> <div class="span12"> <div id="map" class="map"></div> </div> </div> </div> <script> var parser = new ol.format.WMTSCapabilities(); var map; $.ajax('data/WMTSCapabilities.xml').then(function(response) { var result = parser.read(response); var options = ol.source.WMTS.optionsFromCapabilities(result, {layer: 'layer-7328', matrixSet: 'EPSG:3857'}); map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM(), opacity: 0.7 }), new ol.layer.Tile({ opacity: 1, source: new ol.source.WMTS(options) }) ], target: 'map', view: new ol.View({ center: [19412406.33, -5050500.21], zoom: 5 }) }); }); </script> </body> </html>