-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
334 lines (311 loc) · 12.4 KB
/
Copy pathindex.html
File metadata and controls
334 lines (311 loc) · 12.4 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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>9.3 大阅兵 - 国际阵营情况</title>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
<style>
html, body {margin:0; padding:0; width:100%; height:100%; font-family:sans-serif;}
body {display:flex; flex-direction:column; overflow:hidden;}
header {
background: linear-gradient(90deg,#1a237e 0%,#283593 100%);
color:#fff;
display:flex;
flex-wrap: wrap; /* 允许换行 */
align-items:center;
padding:10px 15px;
}
header h1 {
flex:1 1 100%; /* 默认占满整行 */
text-align:center;
margin:0;
font-size:1.5rem;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
.header-buttons {
display:flex;
gap:5px;
margin-left:auto; /* 右对齐 */
flex-wrap:wrap; /* 小屏按钮换行也不会溢出 */
}
header button {
padding:4px 8px;
font-size:0.8rem;
border:none;
border-radius:4px;
cursor:pointer;
background:#1976d2;
color:#fff;
transition:0.2s;
}
header button:hover {
background:#115293;
}
/* 手机端调整 */
@media(max-width:768px){
header h1 {font-size:1.2rem;}
.header-buttons {
width:100%; /* 换行后占满整行 */
justify-content:flex-end; /* 靠右显示 */
margin-top:5px;
}
.header-buttons button {padding:3px 6px; font-size:0.7rem;}
}
.content {display:flex; flex:1; overflow:hidden; position:relative;}
.map-container {flex:1; height:100%; touch-action:none;}
.info-panel {width:300px; background:#f9f9f9; padding:15px; overflow-y:auto; transition: transform 0.3s ease; z-index:100; position:relative;}
.country-item {display:flex; align-items:center; margin:5px 0; padding:5px 8px; background:#fff; border-radius:5px; box-shadow:0 2px 5px rgba(0,0,0,0.05);}
.country-color {width:16px; height:16px; border-radius:50%; margin-right:8px;}
.legend {display:flex; flex-wrap:wrap; justify-content:center; margin:10px 0;}
.legend-item {display:flex; align-items:center; margin:0 10px 5px;}
.legend-color {width:18px; height:18px; border-radius:4px; margin-right:6px;}
.note {text-align:center; font-size:0.85rem; color:#666;}
#toggleList {display:none;}
/* 手机端处理 */
@media (max-width: 768px){
.content {flex-direction: column;}
.map-container {height:70vh; width:100%;}
.info-panel {
position:absolute;
top:70px;
right:0;
width:150px;
max-height:calc(100% - 70px);
background: rgba(249,249,249,0.95);
transform: translateX(100%);
box-shadow:-2px 0 5px rgba(0,0,0,0.2);
}
.info-panel.show {transform: translateX(0);}
#toggleList {display:block; right:10px; top:10px; z-index:101;}
}
</style>
</head>
<body>
<header>
<h1 style="text-align:center; margin: 20px 0;">
<a href="https://github.com/xyy277/map93" target="_blank" style="color: inherit; text-decoration: none;">
9.3 大阅兵 - 国际阵营情况
</a>
</h1>
<div class="header-buttons">
<button id="langSwitch">Switch to English</button>
<button id="labelSwitch">隐藏名称</button>
<button id="toggleList">显示列表</button>
</div>
</header>
<div class="content">
<div id="worldMap" class="map-container"></div>
<div class="info-panel">
<h2>出席国家列表</h2>
<p>共 <strong id="countryCount">0</strong> 个国家</p>
<div id="countryList"></div>
</div>
</div>
<!-- 底部图例 -->
<div class="legend">
<div class="legend-item"><div class="legend-color" style="background:#ff0000"></div>主办国</div>
<div class="legend-item"><div class="legend-color" style="background:#ff4d4f"></div>国家元首或政府首脑</div>
<div class="legend-item"><div class="legend-color" style="background:#1890ff"></div>议长或政府副总理</div>
<div class="legend-item"><div class="legend-color" style="background:#52c41a"></div>高级别代表</div>
<div class="legend-item"><div class="legend-color" style="background:#faad14"></div>前政要</div>
<div class="legend-item"><div class="legend-color" style="background:#d9d9d9"></div>未出席/其他</div>
</div>
<a href="https://github.com/xyy277/map93" target="_blank"
style="
position: fixed;
right: 20px;
bottom: 20px;
background: #24292f;
color: #fff;
padding: 10px 14px;
border-radius: 50px;
font-size: 14px;
font-weight: bold;
text-decoration: none;
box-shadow: 0 2px 6px rgba(0,0,0,0.3);
transition: background 0.3s;
"
onmouseover="this.style.background='#444';"
onmouseout="this.style.background='#24292f';">
⭐ 点个赞吧
</a>
<script>
// 国家元首和政府首脑(value=1)、议长和政府副总理(value=2)、高级别代表(value=3)、前政要(value=4)
const countriesData = [
// 国家元首或政府首脑出席 (value=1)
{name: 'China', en: 'China', label: '中国', value: 0}, // 主办国
{name: 'Russia', en: 'Russia', label: '俄罗斯', value: 1},
{name: 'Dem. Rep. Korea', en: 'Dem. Rep. Korea', label: '朝鲜', value: 1},
{name: 'Cambodia', en: 'Cambodia', label: '柬埔寨', value: 1},
{name: 'Vietnam', en: 'Vietnam', label: '越南', value: 1},
{name: 'Laos', en: 'Laos', label: '老挝', value: 1},
{name: 'Indonesia', en: 'Indonesia', label: '印度尼西亚', value: 1},
{name: 'Malaysia', en: 'Malaysia', label: '马来西亚', value: 1},
{name: 'Mongolia', en: 'Mongolia', label: '蒙古国', value: 1},
{name: 'Pakistan', en: 'Pakistan', label: '巴基斯坦', value: 1},
{name: 'Nepal', en: 'Nepal', label: '尼泊尔', value: 1},
{name: 'Maldives', en: 'Maldives', label: '马尔代夫', value: 1},
{name: 'Kazakhstan', en: 'Kazakhstan', label: '哈萨克斯坦', value: 1},
{name: 'Uzbekistan', en: 'Uzbekistan', label: '乌兹别克斯坦', value: 1},
{name: 'Tajikistan', en: 'Tajikistan', label: '塔吉克斯坦', value: 1},
{name: 'Kyrgyzstan', en: 'Kyrgyzstan', label: '吉尔吉斯斯坦', value: 1},
{name: 'Turkmenistan', en: 'Turkmenistan', label: '土库曼斯坦', value: 1},
{name: 'Belarus', en: 'Belarus', label: '白俄罗斯', value: 1},
{name: 'Azerbaijan', en: 'Azerbaijan', label: '阿塞拜疆', value: 1},
{name: 'Armenia', en: 'Armenia', label: '亚美尼亚', value: 1},
{name: 'Iran', en: 'Iran', label: '伊朗', value: 1},
{name: 'Congo', en: 'Congo', label: '刚果(布)', value: 1},
{name: 'Zimbabwe', en: 'Zimbabwe', label: '津巴布韦', value: 1},
{name: 'Serbia', en: 'Serbia', label: '塞尔维亚', value: 1},
{name: 'Slovakia', en: 'Slovakia', label: '斯洛伐克', value: 1},
{name: 'Cuba', en: 'Cuba', label: '古巴', value: 1},
{name: 'Myanmar', en: 'Myanmar', label: '缅甸', value: 1},
// 议长或政府副总理出席 (value=2)
{name: 'South Korea', en: 'South Korea', label: '韩国', value: 2},
{name: 'Timor-Leste', en: 'Timor-Leste', label: '东帝汶', value: 2},
{name: 'Venezuela', en: 'Venezuela', label: '委内瑞拉', value: 2},
{name: 'Singapore', en: 'Singapore', label: '新加坡', value: 2},
{name: 'Egypt', en: 'Egypt', label: '埃及', value: 2},
{name: 'Bulgaria', en: 'Bulgaria', label: '保加利亚', value: 2},
// 高级别代表出席 (value=3)
{name: 'Brazil', en: 'Brazil', label: '巴西', value: 3},
{name: 'Nicaragua', en: 'Nicaragua', label: '尼加拉瓜', value: 3},
{name: 'Hungary', en: 'Hungary', label: '匈牙利', value: 3},
{name: 'Brunei', en: 'Brunei', label: '文莱', value: 3},
{name: 'Bangladesh', en: 'Bangladesh', label: '孟加拉国', value: 3},
{name: 'Algeria', en: 'Algeria', label: '阿尔及利亚', value: 3},
// 前政要出席 (value=4)
{name: 'Japan', en: 'Japan', label: '日本', value: 4},
{name: 'Switzerland', en: 'Switzerland', label: '瑞士', value: 4},
{name: 'Belgium', en: 'Belgium', label: '比利时', value: 4},
{name: 'Greece', en: 'Greece', label: '希腊', value: 4},
{name: 'Italy', en: 'Italy', label: '意大利', value: 4},
{name: 'Romania', en: 'Romania', label: '罗马尼亚', value: 4},
{name: 'New Zealand', en: 'New Zealand', label: '新西兰', value: 4},
{name: 'Australia', en: 'Australia', label: '澳大利亚', value: 4}
];
// 阵营情况
const colorMap = {};
countriesData.forEach(c => {
if (c.value === 0) {
colorMap[c.name] = '#ff0000'; // 大红色 - 主办国
} else if (c.value === 1) {
colorMap[c.name] = '#ff4d4f'; // 红色 - 领导人出席
} else if (c.value === 2) {
colorMap[c.name] = '#1890ff'; // 蓝色 - 高级代表出席
} else if (c.value === 3) {
colorMap[c.name] = '#52c41a'; // 绿色 - 普通代表出席
} else if (c.value === 4) {
colorMap[c.name] = '#faad14'; // 橙色 - 前政要出席
} else {
colorMap[c.name] = '#d9d9d9'; // 灰色 - 其他情况
}
});
let currentLang='zh';
let showLabels=false;
const chart=echarts.init(document.getElementById('worldMap'));
let worldJsonData=null;
function renderMap(){
fetch('./asset/geo/world.json')
.then(res=>res.json())
.then(worldJson=>{
worldJsonData=worldJson;
echarts.registerMap('world',worldJson);
updateMap();
});
}
function updateMap(){
if(!worldJsonData) return;
const mapData=worldJsonData.features.map(f=>{
const c=countriesData.find(cd=>cd.name===f.properties.name);
return {
name:f.properties.name,
value:c? c.value:0.01,
label:{show:showLabels,formatter:c? (currentLang==='zh'?c.label:c.en):f.properties.name,fontSize:10},
itemStyle:{areaColor:c? colorMap[c.name]:'#f0f0f0'}
};
});
chart.setOption({
tooltip:{formatter:params=>{
const c=countriesData.find(cd=>cd.name===params.name);
return c? `${c.label} / ${c.en}`:params.name;
}},
series:[{
type:'map',
map:'world',
roam:true,
zoom:1,
scaleLimit:{min:0.5,max:5},
data:mapData,
label:{show:showLabels,fontSize:10},
emphasis:{label:{show:true,fontWeight:'bold'},itemStyle:{areaColor:'#2a5caa'}},
itemStyle:{borderColor:'#aaa',borderWidth:0.5}
}]
});
}
// 列表
const attendingCountries=countriesData;
document.getElementById('countryCount').textContent=attendingCountries.length;
const listEl=document.getElementById('countryList');
function renderList(){
listEl.innerHTML='';
attendingCountries.forEach(c=>{
const div=document.createElement('div');
div.className='country-item';
div.innerHTML=`<div class="country-color" style="background-color:${colorMap[c.name]}"></div><span>${currentLang==='zh'?c.label:c.en}</span>`;
listEl.appendChild(div);
});
}
// renderList();
// 按钮事件
document.getElementById('langSwitch').onclick=()=>{
currentLang=currentLang==='zh'?'en':'zh';
document.getElementById('langSwitch').innerText=currentLang==='zh'?'Switch to English':'切换中文';
renderList();
updateMap();
};
document.getElementById('labelSwitch').onclick=()=>{
showLabels=!showLabels;
document.getElementById('labelSwitch').innerText=showLabels?'隐藏名称':'显示名称';
updateMap();
};
const infoPanel=document.querySelector('.info-panel');
const toggleBtn=document.getElementById('toggleList');
// 默认隐藏
infoPanel.style.display = 'none';
toggleBtn.onclick=()=>{
if (infoPanel.style.display === 'none') {
infoPanel.style.display = 'block';
renderList();
} else {
infoPanel.style.display = 'none';
}
infoPanel.classList.toggle('show');
toggleBtn.innerText=infoPanel.classList.contains('show')?'隐藏列表':'显示列表';
};
// 自动检测屏幕大小
function checkScreenMode(){
const isMobile=window.innerWidth<=4396;
if(isMobile){
infoPanel.classList.remove('show');
toggleBtn.innerText='显示列表';
toggleBtn.style.display='block';
} else {
infoPanel.classList.add('show');
toggleBtn.style.display='none';
infoPanel.style.display = 'block';
renderList();
}
}
checkScreenMode();
window.addEventListener('resize',()=>{
chart.resize();
checkScreenMode();
});
renderMap();
</script>
</body>
</html>