<!DOCTYPE html> <html> <head> <title>XYZ Retina Tiles</title> <link rel="stylesheet" href="https://openlayers.org/en/v4.0.1/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> <script src="https://openlayers.org/en/v4.0.1/build/ol.js"></script> </head> <body> <div id="map" class="map"></div> <script> var mapMinZoom = 1; var mapMaxZoom = 15; var mapExtent = [-112.261791, 35.983744, -112.113981, 36.132062]; var map = new ol.Map({ target: 'map', layers: [ new ol.layer.Tile({ source: new ol.source.OSM() }), new ol.layer.Tile({ extent: ol.proj.transformExtent(mapExtent, 'EPSG:4326', 'EPSG:3857'), source: new ol.source.XYZ({ attributions: 'Tiles © USGS, rendered with ' + '<a href="http://www.maptiler.com/">MapTiler</a>', url: 'https://tileserver.maptiler.com/grandcanyon@2x/{z}/{x}/{y}.png', tilePixelRatio: 2, // THIS IS IMPORTANT minZoom: mapMinZoom, maxZoom: mapMaxZoom }) }) ], view: new ol.View({ projection: 'EPSG:3857', center: ol.proj.transform([-112.18688965, 36.057944835], 'EPSG:4326', 'EPSG:3857'), zoom: 12 }) }); </script> </body> </html>
OpenLayers示例代码: XYZ Retina瓦片
Copyright © Since 2014.
开源地理空间基金会中文分会
吉ICP备05002032号
Powered by TorCMS