1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Document</title>
    8. <script src="../lib/include-openlayers-local.js"></script>
    9. </head>
    10. <body>
    11. <div id="map_container">
    12. </div>
    13. <script>
    14. const key = '8a5c2b00e94b49659861e064c37f778d'
    15. /* 天地图矢量图层 */
    16. const TianDiMap_vec = new ol.layer.Tile({
    17. title:"天地图矢量图层",
    18. source:new ol.source.XYZ({
    19. url:'http://t0.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}&tk=' +
    20. key,
    21. wrapX:false
    22. })
    23. })
    24. /* 天地图注记图层 */
    25. const TianDiMap_cva = new ol.layer.Tile({
    26. title:"天地图矢量注记图层",
    27. source:new ol.source.XYZ({
    28. url:'http://t0.tianditu.com/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=' +
    29. key,
    30. wrapX:false
    31. })
    32. })
    33. /* 天地图影像图层 */
    34. const TianDiMap_img = new ol.layer.Tile({
    35. title:"天地图影像图层",
    36. source:new ol.source.XYZ({
    37. url:'http://t0.tianditu.com/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=' +
    38. key,
    39. wrapX:false
    40. })
    41. })
    42. /* 天地图影像注记图层 */
    43. const TianDiMap_cia = new ol.layer.Tile({
    44. title:"天地图影像图层",
    45. source:new ol.source.XYZ({
    46. url:'http://t0.tianditu.com/DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=' +
    47. key,
    48. wrapX:false
    49. })
    50. })
    51. const map = new ol.Map({
    52. target:'map_container',
    53. layers:[TianDiMap_vec,TianDiMap_cva,TianDiMap_img,TianDiMap_cia],
    54. view:new ol.View({
    55. projection:'EPSG:4326',
    56. center:[0,0],
    57. zoom:1
    58. })
    59. })
    60. </script>
    61. </body>
    62. </html>