Example of a XYZ source.
The XYZ source is used for tile data that is accessed through URLs that include a zoom level and tile grid x/y coordinates.
<!DOCTYPE html> <html> <head> <title>XYZ 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 attribution = new ol.Attribution({ html: 'Tiles © <a href="http://maps.nls.uk/townplans/glasgow_1.html">' + 'National Library of Scotland</a>' }); var map = new ol.Map({ target: 'map', controls: ol.control.defaults({ attributionOptions: /** @type {olx.control.AttributionOptions} */ ({ collapsible: false }) }), layers: [ new ol.layer.Tile({ source: new ol.source.OSM({ attributions: [ new ol.Attribution({ html: 'Tiles © <a href="http://www.opencyclemap.org/">' + 'OpenCycleMap</a>' }), ol.source.OSM.ATTRIBUTION ], url: 'http://{a-c}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png' }) }), new ol.layer.Tile({ source: new ol.source.XYZ({ attributions: [attribution], url: 'http://geo.nls.uk/maps/towns/glasgow1857/{z}/{x}/{-y}.png' }) }) ], view: new ol.View({ center: [-472202, 7530279], zoom: 12 }) }); </script> </body> </html>