var projection = ol.proj.get('EPSG:3857'); var projectionExtent = projection.getExtent(); var size = ol.extent.getWidth(projectionExtent) / 256; var resolutions = new Array(20); var matrixIds = new Array(20); for (var z = 0; z < 20; ++z) { resolutions[z] = size / Math.pow(2, z); matrixIds[z] = ("0" + z).slice(-2); } var map = new ol.Map({ layers: [ new ol.layer.Tile({ opacity: 0.7, source: new ol.source.WMTS({ attributions: 'Kaartgegevens: © Kadaster', url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts?', layer: 'brtachtergrondkaart', matrixSet: 'EPSG:3857', format: 'image/png', projection: projection, tileGrid: new ol.tilegrid.WMTS({ origin: ol.extent.getTopLeft(projectionExtent), resolutions: resolutions, matrixIds: matrixIds }), style: 'default', wrapX: false }) }) ], target: 'map-canvas', controls: ol.control.defaults({ attributionOptions: { collapsible: false } }), view: new ol.View({ minZoom: 6, maxZoom: 20, projection: projection, // These coordinates (meters) are in Web Mercator too! center: [631711.827985, 6856275.890632], zoom: 8 }) });