01basemap.html 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>基础地图</title>
  7. <link rel="stylesheet" href="../dist/ol/ol.css" />
  8. <script src="../dist/index.js"></script>
  9. <style>*{padding:0;margin:0;}</style>
  10. </head>
  11. <body>
  12. <div id="map" style="height: 100vh; width: 100vw;"></div>
  13. </body>
  14. <script>
  15. const source = new CTMapOl.source.XYZ({
  16. url: 'http://t0.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=86db5390161c4da2abe96c3fca00f403'
  17. })
  18. const tileLayer = new CTMapOl.layer.Tile({
  19. title: '天地图',
  20. source: source
  21. })
  22. var sourceMarker = new CTMapOl.source.XYZ({
  23. url: 'http://t0.tianditu.gov.cn/cva_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=cva&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=86db5390161c4da2abe96c3fca00f403'
  24. })
  25. const tileMarker = new CTMapOl.layer.Tile({
  26. title: '标注图层',
  27. source: sourceMarker
  28. })
  29. const map = new CTMapOl.Map({
  30. view: new CTMapOl.View({
  31. projection: 'EPSG:3857',
  32. center: CTMapOl.extend.formatLayer.transCooordinateToOpenlayer([116.39, 39.91]),
  33. // center: [0, 0],
  34. zoom: 16,
  35. maxZoom: 18,
  36. minZoom: 1
  37. }),
  38. layers: [tileLayer, tileMarker],
  39. target: 'map'
  40. })
  41. </script>
  42. </html>