智慧水务管理系统 - 精河县供水工程综合管理平台

index.html 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>GIS地图系统</title>
  7. <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
  8. <style>
  9. body { margin: 0; padding: 0; font-family: Arial, sans-serif; }
  10. #map { height: 600px; width: 100%; }
  11. .map-controls {
  12. position: absolute;
  13. top: 10px;
  14. right: 10px;
  15. background: white;
  16. padding: 10px;
  17. border-radius: 5px;
  18. box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  19. z-index: 1000;
  20. }
  21. .control-group {
  22. margin-bottom: 10px;
  23. }
  24. .control-group label {
  25. display: block;
  26. margin-bottom: 5px;
  27. font-weight: bold;
  28. }
  29. .control-group select, .control-group button {
  30. width: 100%;
  31. padding: 5px;
  32. border: 1px solid #ccc;
  33. border-radius: 3px;
  34. }
  35. .device-popup {
  36. text-align: center;
  37. }
  38. .device-popup h4 {
  39. margin: 0 0 5px 0;
  40. color: #2c3e50;
  41. }
  42. .device-popup p {
  43. margin: 0;
  44. font-size: 12px;
  45. }
  46. </style>
  47. </head>
  48. <body>
  49. <div id="map"></div>
  50. <div class="map-controls">
  51. <div class="control-group">
  52. <label>底图选择</label>
  53. <select id="baseMapSelect">
  54. <option value="osm">OpenStreetMap</option>
  55. <option value="satellite">卫星影像</option>
  56. <option value="terrain">地形图</option>
  57. </select>
  58. </div>
  59. <div class="control-group">
  60. <label>图层控制</label>
  61. <div>
  62. <label><input type="checkbox" id="deviceLayer" checked> 监测点位</label><br>
  63. <label><input type="checkbox" id="pipeLayer" checked> 管网数据</label><br>
  64. <label><input type="checkbox" id="trajectoryLayer"> 轨迹回放</label>
  65. </div>
  66. </div>
  67. <div class="control-group">
  68. <button onclick="refreshData()">刷新数据</button>
  69. </div>
  70. </div>
  71. <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
  72. <script>
  73. // 初始化地图
  74. let map = L.map('map').setView([44.0321, 82.8973], 10);
  75. // 底图图层
  76. let osmLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  77. attribution: '© OpenStreetMap contributors'
  78. });
  79. let satelliteLayer = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
  80. attribution: '© Esri'
  81. });
  82. let terrainLayer = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
  83. attribution: '© OpenTopoMap contributors'
  84. });
  85. osmLayer.addTo(map);
  86. // 监测点位图层
  87. let deviceLayer = L.layerGroup();
  88. let pipeLayer = L.layerGroup();
  89. let trajectoryLayer = L.layerGroup();
  90. // 加载监测点位数据
  91. function loadDevices() {
  92. fetch('/api/gis/devices')
  93. .then(response => response.json())
  94. .then(devices => {
  95. deviceLayer.clearLayers();
  96. devices.forEach(device => {
  97. let marker = L.marker([device.latitude, device.longitude])
  98. .bindPopup(`
  99. <div class="device-popup">
  100. <h4>${device.name}</h4>
  101. <p>编码: ${device.deviceCode}</p>
  102. <p>类型: ${device.deviceType}</p>
  103. </div>
  104. `);
  105. deviceLayer.addLayer(marker);
  106. });
  107. });
  108. }
  109. // 加载管网数据(模拟)
  110. function loadPipes() {
  111. pipeLayer.clearLayers();
  112. // 这里可以添加实际的管网数据加载逻辑
  113. let polyline = L.polyline([
  114. [44.0321, 82.8973],
  115. [44.0365, 82.9058],
  116. [44.0410, 82.9143]
  117. ], {
  118. color: '#0066cc',
  119. weight: 3
  120. });
  121. pipeLayer.addLayer(polyline);
  122. }
  123. // 地图切换控制
  124. document.getElementById('baseMapSelect').addEventListener('change', function(e) {
  125. // 移除所有底图
  126. map.eachLayer(layer => {
  127. if (layer instanceof L.TileLayer) {
  128. map.removeLayer(layer);
  129. }
  130. });
  131. // 添加选中的底图
  132. switch(e.target.value) {
  133. case 'osm':
  134. osmLayer.addTo(map);
  135. break;
  136. case 'satellite':
  137. satelliteLayer.addTo(map);
  138. break;
  139. case 'terrain':
  140. terrainLayer.addTo(map);
  141. break;
  142. }
  143. });
  144. // 图层控制
  145. document.getElementById('deviceLayer').addEventListener('change', function(e) {
  146. if (e.target.checked) {
  147. map.addLayer(deviceLayer);
  148. } else {
  149. map.removeLayer(deviceLayer);
  150. }
  151. });
  152. document.getElementById('pipeLayer').addEventListener('change', function(e) {
  153. if (e.target.checked) {
  154. map.addLayer(pipeLayer);
  155. } else {
  156. map.removeLayer(pipeLayer);
  157. }
  158. });
  159. document.getElementById('trajectoryLayer').addEventListener('change', function(e) {
  160. if (e.target.checked) {
  161. map.addLayer(trajectoryLayer);
  162. } else {
  163. map.removeLayer(trajectoryLayer);
  164. }
  165. });
  166. // 刷新数据
  167. function refreshData() {
  168. loadDevices();
  169. loadPipes();
  170. }
  171. // 初始加载数据
  172. loadDevices();
  173. loadPipes();
  174. map.addLayer(deviceLayer);
  175. map.addLayer(pipeLayer);
  176. // 地图事件监听
  177. map.on('click', function(e) {
  178. console.log('地图点击位置:', e.latlng);
  179. });
  180. </script>
  181. </body>
  182. </html>