09SearchDemo_map.html 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. </head>
  10. <body style="margin: 0; padding: 0;">
  11. <!-- <div id="map" style="height: 100vh; width: 100vw"></div> -->
  12. <div id="mapId" class="mapDIV"></div>
  13. <div class="input-card4">
  14. 天地图模糊搜索<br>
  15. <div><input type="text" id="keyWordQueryRedirect_tdtInput"></div>
  16. <div class="input-item">
  17. <button class="btn" onclick="keyWordQuery_tdt()">查询</button>
  18. </div>
  19. <div><input type="text" id="keyWordQueryRedirect_tdtOut"></div>
  20. </div>
  21. </body>
  22. <script>
  23. const source = new CTMapOl.source.XYZ({
  24. 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'
  25. })
  26. const tileLayer = new CTMapOl.layer.Tile({
  27. title: '天地图',
  28. source: source
  29. })
  30. var sourceMarker = new CTMapOl.source.XYZ({
  31. 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'
  32. })
  33. const tileMarker = new CTMapOl.layer.Tile({
  34. title: '标注图层',
  35. source: sourceMarker
  36. })
  37. const map = new CTMapOl.Map({
  38. view: new CTMapOl.View({
  39. projection: 'EPSG:4326',
  40. center: [124.6112610521188, 41.530759008113655],
  41. zoom: 10,
  42. maxZoom: 18,
  43. minZoom: 1
  44. }),
  45. controls: CTMapOl.control.defaults({
  46. attribution: false,
  47. rotate: false,
  48. zoom: false
  49. }),
  50. layers: [tileLayer, tileMarker],
  51. target: 'mapId'
  52. })
  53. function keyWordQuery_tdt() {
  54. var oBtn = document.getElementById("keyWordQueryRedirect_tdtInput")
  55. var oIpt = document.getElementById("keyWordQueryRedirect_tdtOut")
  56. oIpt.value = oBtn.value;
  57. let ss = CTMapOl.api.keyWordQuery_tdt(map, "沙河");
  58. ss.then(res => {
  59. oIpt.value = res.data;
  60. });
  61. }
  62. </script>
  63. <style>
  64. /*地图*/
  65. .mapDIV {
  66. height: 100vh;
  67. width: 100vw;
  68. z-index: 1;
  69. }
  70. .add-switch {
  71. position: absolute;
  72. right: 30px;
  73. height: 68px;
  74. width: 30px;
  75. bottom: 112px;
  76. background: #FFFFFF 100%;
  77. color: #172537;
  78. border-radius: 4px;
  79. display: flex;
  80. flex-direction: column;
  81. align-items: center;
  82. z-index: 2;
  83. }
  84. .add-s-block {
  85. height: 20px;
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. width: 100%;
  90. line-height: 20px;
  91. font-size: 12px;
  92. margin-bottom: 2px;
  93. color: #172537;
  94. }
  95. .add-zoom {
  96. width: 20px;
  97. height: 20px;
  98. background-image: url('../dist/assets/image/ar/switch/add-zoom.svg');
  99. background-size: 100% 100%;
  100. cursor: pointer;
  101. }
  102. .sub-zoom {
  103. width: 20px;
  104. height: 20px;
  105. background-image: url('../dist/assets/image/ar/switch/sub-zoom.svg');
  106. background-size: 100% 100%;
  107. cursor: pointer;
  108. }
  109. .add-zoom-out {
  110. width: 20px;
  111. height: 20px;
  112. background-image: url('../dist/assets/image/ar/switch/add-zoom-out.svg');
  113. background-size: 100% 100%;
  114. }
  115. .sub-zoom-out {
  116. width: 20px;
  117. height: 20px;
  118. background-image: url('../dist/assets/image/ar/switch/sub-zoom-out.svg');
  119. background-size: 100% 100%;
  120. }
  121. .add-s-block.btn-click {
  122. cursor: pointer;
  123. }
  124. .input-card {
  125. position: absolute;
  126. right: 15px;
  127. bottom: 15px;
  128. z-index: 999;
  129. }
  130. .input-card4 {
  131. position: absolute;
  132. left: 50px;
  133. top: 650px;
  134. z-index: 999;
  135. }
  136. </style>
  137. </html>