goog.require('ol.Map'); goog.require('ol.View2D'); goog.require('ol.extent'); goog.require('ol.layer.Tile'); goog.require('ol.proj'); goog.require('ol.source.OSM'); goog.require('ol.source.WMTS'); goog.require('ol.tilegrid.WMTS'); var projection = ol.proj.get('EPSG:900913'); var projectionExtent = projection.getExtent(); var size = ol.extent.getWidth(projectionExtent) / 256; var resolutions = new Array(26); var matrixIds = new Array(26); for (var z = 0; z < 26; ++z) { // generate resolutions and matrixIds arrays for this WMTS resolutions[z] = size / Math.pow(2, z); matrixIds[z] = 'EPSG:900913:' + z; } var map = new ol.Map({ layers: [ new ol.layer.Tile({ source: new ol.source.OSM(), opacity: 0.7 }), new ol.layer.Tile({ source: new ol.source.WMTS({ url: 'http://v2.suite.opengeo.org/geoserver/gwc/service/wmts/', layer: 'medford:buildings', matrixSet: 'EPSG:900913', format: 'image/png', projection: projection, tileGrid: new ol.tilegrid.WMTS({ origin: ol.extent.getTopLeft(projectionExtent), resolutions: resolutions, matrixIds: matrixIds }), style: '_null', extent: [-13682835, 5204068, -13667473, 5221690] }) }) ], renderer: 'canvas', target: 'map', view: new ol.View2D({ center: [-13677832, 5213272], zoom: 13 }) });