|
|
@@ -0,0 +1,198 @@
|
|
|
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
|
+
|
|
|
72
|
+ <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
|
|
|
73
|
+ <script>
|
|
|
74
|
+ // 初始化地图
|
|
|
75
|
+ let map = L.map('map').setView([44.0321, 82.8973], 10);
|
|
|
76
|
+
|
|
|
77
|
+ // 底图图层
|
|
|
78
|
+ let osmLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
|
79
|
+ attribution: '© OpenStreetMap contributors'
|
|
|
80
|
+ });
|
|
|
81
|
+
|
|
|
82
|
+ let satelliteLayer = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
|
|
|
83
|
+ attribution: '© Esri'
|
|
|
84
|
+ });
|
|
|
85
|
+
|
|
|
86
|
+ let terrainLayer = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
|
|
|
87
|
+ attribution: '© OpenTopoMap contributors'
|
|
|
88
|
+ });
|
|
|
89
|
+
|
|
|
90
|
+ osmLayer.addTo(map);
|
|
|
91
|
+
|
|
|
92
|
+ // 监测点位图层
|
|
|
93
|
+ let deviceLayer = L.layerGroup();
|
|
|
94
|
+ let pipeLayer = L.layerGroup();
|
|
|
95
|
+ let trajectoryLayer = L.layerGroup();
|
|
|
96
|
+
|
|
|
97
|
+ // 加载监测点位数据
|
|
|
98
|
+ function loadDevices() {
|
|
|
99
|
+ fetch('/api/gis/devices')
|
|
|
100
|
+ .then(response => response.json())
|
|
|
101
|
+ .then(devices => {
|
|
|
102
|
+ deviceLayer.clearLayers();
|
|
|
103
|
+ devices.forEach(device => {
|
|
|
104
|
+ let marker = L.marker([device.latitude, device.longitude])
|
|
|
105
|
+ .bindPopup(`
|
|
|
106
|
+ <div class="device-popup">
|
|
|
107
|
+ <h4>${device.name}</h4>
|
|
|
108
|
+ <p>编码: ${device.deviceCode}</p>
|
|
|
109
|
+ <p>类型: ${device.deviceType}</p>
|
|
|
110
|
+ </div>
|
|
|
111
|
+ `);
|
|
|
112
|
+ deviceLayer.addLayer(marker);
|
|
|
113
|
+ });
|
|
|
114
|
+ });
|
|
|
115
|
+ }
|
|
|
116
|
+
|
|
|
117
|
+ // 加载管网数据(模拟)
|
|
|
118
|
+ function loadPipes() {
|
|
|
119
|
+ pipeLayer.clearLayers();
|
|
|
120
|
+ // 这里可以添加实际的管网数据加载逻辑
|
|
|
121
|
+ let polyline = L.polyline([
|
|
|
122
|
+ [44.0321, 82.8973],
|
|
|
123
|
+ [44.0365, 82.9058],
|
|
|
124
|
+ [44.0410, 82.9143]
|
|
|
125
|
+ ], {
|
|
|
126
|
+ color: '#0066cc',
|
|
|
127
|
+ weight: 3
|
|
|
128
|
+ });
|
|
|
129
|
+ pipeLayer.addLayer(polyline);
|
|
|
130
|
+ }
|
|
|
131
|
+
|
|
|
132
|
+ // 地图切换控制
|
|
|
133
|
+ document.getElementById('baseMapSelect').addEventListener('change', function(e) {
|
|
|
134
|
+ // 移除所有底图
|
|
|
135
|
+ map.eachLayer(layer => {
|
|
|
136
|
+ if (layer instanceof L.TileLayer) {
|
|
|
137
|
+ map.removeLayer(layer);
|
|
|
138
|
+ }
|
|
|
139
|
+ });
|
|
|
140
|
+
|
|
|
141
|
+ // 添加选中的底图
|
|
|
142
|
+ switch(e.target.value) {
|
|
|
143
|
+ case 'osm':
|
|
|
144
|
+ osmLayer.addTo(map);
|
|
|
145
|
+ break;
|
|
|
146
|
+ case 'satellite':
|
|
|
147
|
+ satelliteLayer.addTo(map);
|
|
|
148
|
+ break;
|
|
|
149
|
+ case 'terrain':
|
|
|
150
|
+ terrainLayer.addTo(map);
|
|
|
151
|
+ break;
|
|
|
152
|
+ }
|
|
|
153
|
+ });
|
|
|
154
|
+
|
|
|
155
|
+ // 图层控制
|
|
|
156
|
+ document.getElementById('deviceLayer').addEventListener('change', function(e) {
|
|
|
157
|
+ if (e.target.checked) {
|
|
|
158
|
+ map.addLayer(deviceLayer);
|
|
|
159
|
+ } else {
|
|
|
160
|
+ map.removeLayer(deviceLayer);
|
|
|
161
|
+ }
|
|
|
162
|
+ });
|
|
|
163
|
+
|
|
|
164
|
+ document.getElementById('pipeLayer').addEventListener('change', function(e) {
|
|
|
165
|
+ if (e.target.checked) {
|
|
|
166
|
+ map.addLayer(pipeLayer);
|
|
|
167
|
+ } else {
|
|
|
168
|
+ map.removeLayer(pipeLayer);
|
|
|
169
|
+ }
|
|
|
170
|
+ });
|
|
|
171
|
+
|
|
|
172
|
+ document.getElementById('trajectoryLayer').addEventListener('change', function(e) {
|
|
|
173
|
+ if (e.target.checked) {
|
|
|
174
|
+ map.addLayer(trajectoryLayer);
|
|
|
175
|
+ } else {
|
|
|
176
|
+ map.removeLayer(trajectoryLayer);
|
|
|
177
|
+ }
|
|
|
178
|
+ });
|
|
|
179
|
+
|
|
|
180
|
+ // 刷新数据
|
|
|
181
|
+ function refreshData() {
|
|
|
182
|
+ loadDevices();
|
|
|
183
|
+ loadPipes();
|
|
|
184
|
+ }
|
|
|
185
|
+
|
|
|
186
|
+ // 初始加载数据
|
|
|
187
|
+ loadDevices();
|
|
|
188
|
+ loadPipes();
|
|
|
189
|
+ map.addLayer(deviceLayer);
|
|
|
190
|
+ map.addLayer(pipeLayer);
|
|
|
191
|
+
|
|
|
192
|
+ // 地图事件监听
|
|
|
193
|
+ map.on('click', function(e) {
|
|
|
194
|
+ console.log('地图点击位置:', e.latlng);
|
|
|
195
|
+ });
|
|
|
196
|
+ </script>
|
|
|
197
|
+</body>
|
|
|
198
|
+</html>
|