1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
| <!doctype html> <html lang="en">
<head> <meta charset="utf-8"> <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/openlayers/8.1.0/ol.min.css" type="text/css"> <style> .map { height: 400px; width: 100%; } </style> <script src="https://cdn.bootcdn.net/ajax/libs/openlayers/8.1.0/dist/ol.js"></script> <title>OpenLayers example</title> </head>
<body> <h2>My Map</h2> <div id="map" class="map"></div> </body> <script type="text/javascript"> let key = `这里填写你的天地图密钥,可自行去官网申请`
var img_w = new ol.layer.Tile({ title: "影像图", source: new ol.source.XYZ({ url: "http://t{0-7}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=" + key + "", }), }); var cia_w = new ol.layer.Tile({ title: "影像图文字标注", source: new ol.source.XYZ({ url: "http://t{0-7}.tianditu.gov.cn/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=" + key + "", }), });
let view = new ol.View({ center: ol.proj.fromLonLat([111.32034, 38.27778]), zoom: 12, })
var map = new ol.Map({ target: 'map', layers: [img_w, cia_w], view: view,
}); </script>
</html>
|