-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreal-map.html
More file actions
265 lines (233 loc) · 8.97 KB
/
real-map.html
File metadata and controls
265 lines (233 loc) · 8.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>中国行政区划学习 - 真实地图版</title>
<link rel="stylesheet" href="styles.css">
<style>
/* 针对真实地图的额外样式 */
.loading-indicator {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
margin: 20px 0;
}
.data-source-info {
background: #f0f8ff;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
border-left: 4px solid #4299e1;
}
.data-source-info h3 {
margin: 0 0 10px 0;
color: #2b6cb0;
font-size: 1rem;
}
.data-source-info p {
margin: 0;
font-size: 0.9rem;
color: #4a5568;
}
.error-message {
background: #fed7d7;
color: #c53030;
padding: 15px;
border-radius: 8px;
margin: 10px 0;
border-left: 4px solid #e53e3e;
}
.network-status {
position: fixed;
top: 10px;
right: 10px;
background: rgba(0,0,0,0.8);
color: white;
padding: 8px 12px;
border-radius: 20px;
font-size: 12px;
z-index: 1000;
}
.network-status.online {
background: #48bb78;
}
.network-status.offline {
background: #e53e3e;
}
/* 真实地图的省份样式调整 */
.province {
fill: #e2e8f0;
stroke: #a0aec0;
stroke-width: 0.5;
cursor: pointer;
transition: all 0.2s ease;
}
.province:hover {
fill: #4299e1;
stroke: #2b6cb0;
stroke-width: 1;
}
.province.highlighted {
fill: #48bb78;
stroke: #2f855a;
stroke-width: 1;
}
.province.current {
fill: #ed8936;
stroke: #c05621;
stroke-width: 2;
}
/* 移动端优化 */
@media (max-width: 768px) {
.data-source-info {
font-size: 0.8rem;
padding: 10px;
}
.network-status {
font-size: 10px;
padding: 6px 10px;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>🗺️ 中国行政区划学习</h1>
<p>使用真实地理数据的专业版本</p>
</header>
<main>
<!-- 数据源信息 -->
<div class="data-source-info">
<h3>🌐 真实地图数据</h3>
<p>本应用使用阿里云DataV提供的官方中国行政区划GeoJSON数据,确保地理信息的准确性和权威性。</p>
</div>
<!-- 全国地图视图 -->
<div id="chinaMapView" class="map-view active">
<h2>中国地图</h2>
<div class="map-container">
<svg id="chinaMap" viewBox="0 0 1000 800">
<!-- 真实的中国地图将通过JavaScript动态生成 -->
<text x="500" y="400" text-anchor="middle" font-size="18" fill="#666">
正在加载真实地图数据...
</text>
</svg>
</div>
<div class="controls">
<button id="startLearning" class="btn btn-primary" disabled>开始学习</button>
<button id="randomProvince" class="btn btn-secondary" disabled>随机选择省份</button>
</div>
</div>
<!-- 省份学习视图 -->
<div id="provinceView" class="map-view">
<div class="province-header">
<h2 id="provinceTitle">省份学习</h2>
<div class="progress">
<span id="progressText">准备开始</span>
</div>
</div>
<div class="map-container">
<svg id="provinceMap" viewBox="0 0 600 400">
<!-- 省份详细地图将通过JavaScript动态生成 -->
</svg>
</div>
<div class="controls">
<button id="showProvinceName" class="btn btn-primary" disabled>显示省份名称</button>
<button id="showCapital" class="btn btn-secondary" disabled>显示省会</button>
<button id="nextProvince" class="btn btn-success" disabled>下一个省份</button>
<button id="backToChina" class="btn btn-outline">返回全国地图</button>
</div>
<!-- 答案显示区域 -->
<div id="answerArea" class="answer-area">
<div id="provinceName" class="answer-item hidden">
<h3>省份名称</h3>
<p id="provinceNameText"></p>
</div>
<div id="capitalInfo" class="answer-item hidden">
<h3>省会城市</h3>
<p id="capitalNameText"></p>
</div>
</div>
</div>
<!-- 统计面板 -->
<div class="stats-panel">
<div class="stat-item">
<span class="stat-label">已学习:</span>
<span id="learnedCount">0</span>
</div>
<div class="stat-item">
<span class="stat-label">总数:</span>
<span id="totalCount">加载中...</span>
</div>
</div>
</main>
<footer>
<p>💡 提示:使用真实地理数据,提供准确的学习体验</p>
<p style="font-size: 0.8rem; opacity: 0.7;">数据来源:阿里云DataV | 键盘快捷键:1-显示名称 2-显示省会 3-下一个 ESC-返回</p>
</footer>
</div>
<!-- 网络状态指示器 -->
<div id="networkStatus" class="network-status">检查网络连接...</div>
<!-- 错误提示区域 -->
<div id="errorContainer"></div>
<!-- JavaScript 文件加载 -->
<script src="geo-data-loader.js"></script>
<script src="real-map-app.js"></script>
<script>
// 网络状态监测
function updateNetworkStatus() {
const statusIndicator = document.getElementById('networkStatus');
if (navigator.onLine) {
statusIndicator.textContent = '在线';
statusIndicator.className = 'network-status online';
setTimeout(() => {
statusIndicator.style.display = 'none';
}, 3000);
} else {
statusIndicator.textContent = '离线';
statusIndicator.className = 'network-status offline';
statusIndicator.style.display = 'block';
}
}
// 监听网络状态变化
window.addEventListener('online', updateNetworkStatus);
window.addEventListener('offline', updateNetworkStatus);
// 初始化网络状态
document.addEventListener('DOMContentLoaded', () => {
updateNetworkStatus();
});
// 全局错误处理
window.addEventListener('error', (e) => {
console.error('应用错误:', e.error);
const errorContainer = document.getElementById('errorContainer');
const errorDiv = document.createElement('div');
errorDiv.className = 'error-message';
errorDiv.innerHTML = `
<strong>应用错误</strong><br>
${e.message || '未知错误,请刷新页面重试'}
`;
errorContainer.appendChild(errorDiv);
// 5秒后自动隐藏错误消息
setTimeout(() => {
if (errorDiv.parentNode) {
errorDiv.parentNode.removeChild(errorDiv);
}
}, 5000);
});
// 未处理的Promise拒绝
window.addEventListener('unhandledrejection', (e) => {
console.error('未处理的Promise拒绝:', e.reason);
const errorContainer = document.getElementById('errorContainer');
const errorDiv = document.createElement('div');
errorDiv.className = 'error-message';
errorDiv.innerHTML = `
<strong>数据加载错误</strong><br>
请检查网络连接并刷新页面
`;
errorContainer.appendChild(errorDiv);
});
</script>
</body>
</html>