-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
581 lines (511 loc) · 24.6 KB
/
index.html
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
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="description" content="英超球队都在哪里?英超地图可视化的展示了从1992-2019每个赛季的英超球队主场分布.点击球队队徽可以看到当赛季球队的荣誉(欧冠,欧联,优胜者杯,英超,足总杯,联赛杯,世俱杯)和历史荣誉(最近一座冠军,最近一座联赛冠军)">
<meta name="keywords" content="英超球队分布,英超地图,英超地理,英超历史,英超分布,英超俱乐部地图,英超球队地理分布,英超球队所在地,英超20强,英格兰足球地图" />
<title>英超地图 1992-2020</title>
<link rel="icon" href="./favicon.ico" type="image/x-icon"/>
<link rel="shortcut icon" href="./favicon.ico" type="image/x-icon"/>
<script type="text/javascript"
src="https://api.map.baidu.com/api?v=2.0&ak=pvBQzudwqbcrYnoAHEorEnHVe8ouuL6w"></script>
<!-- <script type="text/javascript" src="//api.map.baidu.com/library/AreaRestriction/1.2/src/AreaRestriction_min.js"></script> -->
<script src="js/autogenerate.js"></script>
<script src="js/gps.js"></script>
<script src="js/derby.js"></script>
<script src="js/foundation.js"></script>
<script src="js/logo.js"></script>
<script src="js/promotion.js"></script>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/i18next.min.js"></script>
<script src="js/i18nextXHRBackend.js"></script>
<script src="js/i18nextBrowserLanguageDetector.js"></script>
</head>
<body>
<style type="text/css">
html {
height: 100%
}
body {
height: 100%;
}
#container {
height: 100%;
}
#promotion {
margin-left: 10px;
}
#degradation {
margin-left: 10px;
}
#promotion_and_degradation {
margin-left: 10px;
}
tr.separated td {
/* set border style for separated rows */
border-top: 1px solid black;
}
tr.separated th {
/* set border style for separated rows */
border-top: 1px solid black;
}
</style>
<div id="container"></div>
<script type="text/javascript">
//show in console
console.log(logo)
console.log("source code: https://github.com/lengyijun/map_of_the_premier_league");
console.log("If you have any advice, feel free to put it here: https://github.com/lengyijun/map_of_the_premier_league/issues");
const PL = "Premier League";
const FA = "Football Association Challenge Cup";
const EFL = "English Football League Cup";
const UCL = "UEFA Champion League";
const UEL = "UEFA Europa League";
const CWC = "UEFA Cup Winners' Cup";
const FCWC = "FIFA Club World Cup";
i18next
.use(i18nextXHRBackend)
.use(i18nextBrowserLanguageDetector)
.init({
fallbackLng: 'zh',
debug: true,
ns: ['common'],
defaultNS: 'common',
backend: {
loadPath: 'locales/{{lng}}/{{ns}}.json',
crossDomain: true
}
}, function (err, t) {
document.title=i18next.t( "documentTitle" );
// init set content
document.getElementById("ucl").title = i18next.t("title.UEFA Champion League");
document.getElementById("uel").title = i18next.t("title.UEFA Europa League");
document.getElementById("cwc").title = i18next.t("title.UEFA Cup Winners' Cup");
document.getElementById("pl").title = i18next.t("title.Premier League");
document.getElementById("fa").title = i18next.t("title.Football Association Challenge Cup");
document.getElementById("efl").title = i18next.t("title.English Football League Cup");
document.getElementById("fcwc").title = i18next.t("title.FIFA Club World Cup");
updateMap("2019-20");
});
let map = new BMap.Map("container"); //初始化地图
//温布利球场
map.centerAndZoom(new BMap.Point(-0.279530, 51.556141), 8);
map.setMinZoom(8);
map.enableScrollWheelZoom();//滚轮放大缩小。
map.addControl(new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_LARGE}));
// 定义一个控件类,即function
function SeasonControl() {
// 设置默认停靠位置和偏移量
this.defaultAnchor = BMAP_ANCHOR_TOP_LEFT;
<!-- this.defaultOffset = new BMap.Size(10, 10); -->
}
// 通过JavaScript的prototype属性继承于BMap.Control
SeasonControl.prototype = new BMap.Control();
// 自定义控件必须实现initialize方法,并且将控件的DOM元素返回
// 在本方法中创建个div元素作为控件的容器,并将其添加到地图容器中
SeasonControl.prototype.initialize = function (map) {
let div = document.createElement("div");
let parser = new DOMParser();
const yearHtml =
`
<select id="year" onChange="updateMap(this.value);" >
<option value="2020-21">2020-21</option>
<option value="2019-20" selected="selected">2019-20</option>
<option value="2018-19">2018-19</option>
<option value="2017-18">2017-18</option>
<option value="2016-17">2016-17</option>
<option value="2015-16">2015-16</option>
<option value="2014-15">2014-15</option>
<option value="2013-14">2013-14</option>
<option value="2012-13">2012-13</option>
<option value="2011-12">2011-12</option>
<option value="2010-11">2010-11</option>
<option value="2009-10">2009-10</option>
<option value="2008-09">2008-09</option>
<option value="2007-08">2007-08</option>
<option value="2006-07">2006-07</option>
<option value="2005-06">2005-06</option>
<option value="2004-05">2004-05</option>
<option value="2003-04">2003-04</option>
<option value="2002-03">2002-03</option>
<option value="2001-02">2001-02</option>
<option value="2000-01">2000-01</option>
<option value="1999-2000">1999-2000</option>
<option value="1998-99">1998-99</option>
<option value="1997-98">1997-98</option>
<option value="1996-97">1996-97</option>
<option value="1995-96">1995-96</option>
<option value="1994-95">1994-95</option>
<option value="1993-94">1993-94</option>
<option value="1992-93">1992-93</option>
</select>
`;
let honorHtml = `
<div id="honor">
<img id="ucl" src="img/trophy-grey/ucl-trophy.svg" width="50px" />
<img id="pl" src="img/trophy-grey/pl-trophy.svg" width="50px" />
<img id="uel" src="img/trophy-grey/uel-trophy.svg" width="50px" />
<img id="cwc" src="img/trophy-grey/cwc-trophy.svg" width="50px" />
<img id="fa" src="img/trophy-grey/fa-trophy.svg" width="50px" />
<img id="efl" src="img/trophy-grey/efl-trophy.svg" width="50px" />
<img id="fcwc" src="img/trophy-grey/fcwc-trophy.svg" width="50px" />
</div>
`;
let year = parser.parseFromString(yearHtml, 'text/html');
year = year.body.firstChild;
let honor = parser.parseFromString(honorHtml, 'text/html');
honor = honor.body.firstChild;
div.style["margin-left"] = "5px";
year.style["font-size"] = "30px";
year.style["margin-top"] = "10px";
honor.style["margin-top"] = "5px";
div.appendChild(year);
div.appendChild(honor);
// 添加DOM元素到地图中
map.getContainer().appendChild(div);
// 将DOM元素返回
return div;
};
// 创建控件实例
let mySeasonControl = new SeasonControl();
// 添加到地图当中
map.addControl(mySeasonControl);
<!-- 视野,但是效果不好 -->
<!-- let b = new BMap.Bounds(new BMap.Point( -5.643557, 50.084403 ),new BMap.Point( 0.04, 55.119193 )); -->
<!-- try{ -->
<!-- BMapLib.AreaRestriction.setBounds(map, b); -->
<!-- } catch (e) { -->
<!-- alert(e); -->
<!-- } -->
function _showTitleInfo(season) {
return function (marker, name, title) {
marker.addEventListener("click", function () {
let sContent = "";
if (title === FA) {
const x = FA_final[season];
sContent += i18next.t('team.' + x[0]);
sContent += " ";
sContent += x[1];
sContent += " ";
sContent += i18next.t('team.' + x[2],x[2]);
sContent += "<br>";
}
if (title === EFL) {
const x = EFL_final[season];
sContent += i18next.t('team.' + x[0]);
sContent += " ";
sContent += x[1];
sContent += " ";
sContent += i18next.t('team.' + x[2],x[2]);
sContent += "<br>";
}
if (title === CWC) {
const x = CWC_final[season];
sContent += i18next.t('team.' + x[0]);
sContent += " ";
sContent += x[1];
sContent += " ";
sContent += i18next.t('team.' + x[2],x[2]);
sContent += "<br>";
}
if (title === UCL) {
const x = UCL_final[season];
sContent += i18next.t('team.' + x[0]);
sContent += " ";
sContent += x[1];
sContent += " ";
sContent += i18next.t('team.' + x[2],x[2]);
sContent += "<br>";
}
if (title === UEL) {
const x = UEL_final[season];
sContent += i18next.t('team.' + x[0]);
sContent += " ";
sContent += x[1];
sContent += " ";
sContent += i18next.t('team.' + x[2],x[2]);
sContent += "<br>";
}
sContent +=
i18next.t('team.' + name)
+ i18next.t('other.win')
+ " "
+ season
+ " "
+ i18next.t('title.' + title)
+ i18next.t('other.champion');
let infoWindow = new BMap.InfoWindow(sContent, {enableMessage: false});// 创建信息窗口对象
marker.openInfoWindow(infoWindow);
});
}
}
function updateMap(season) {
map.clearOverlays();
document.getElementById("ucl").onclick = undefined;
document.getElementById("uel").onclick = undefined;
document.getElementById("cwc").onclick = undefined;
document.getElementById("pl").onclick = undefined;
document.getElementById("fa").onclick = undefined;
document.getElementById("efl").onclick = undefined;
document.getElementById("fcwc").onclick = undefined;
document.getElementById("ucl").src = "img/trophy-grey/ucl-trophy.svg";
document.getElementById("uel").src = "img/trophy-grey/uel-trophy.svg";
document.getElementById("cwc").src = "img/trophy-grey/cwc-trophy.svg";
document.getElementById("pl").src = "img/trophy-grey/pl-trophy.svg";
document.getElementById("fa").src = "img/trophy-grey/fa-trophy.svg";
document.getElementById("efl").src = "img/trophy-grey/efl-trophy.svg";
document.getElementById("fcwc").src = "img/trophy-grey/fcwc-trophy.svg";
const filename = "PLdata/" + season + ".json";
const year = parseInt(season);
let showTitleInfo = _showTitleInfo(season);
$.getJSON(filename, function (data) {
const teams = data.tables[0].entries;
addMarker(teams);//添加标注。
function addMarker(teams) { // 创建图标对象
let marker;
//处理重叠的球队,使用同一主场
//在英超,只有水晶宫和温布尔顿
let heightOffset = {};
teams.forEach((team, _1, _2) => {
let point;
const location = team.ground.location;
const name = team.team.name;
const groundName = team.ground.name;
function centerOnTeam() {
map.centerAndZoom(point, 20);
}
if (location !== undefined) {
point = new BMap.Point(location.longitude, location.latitude);
} else {
const location = complementaryGPS[groundName];
point = new BMap.Point(location.longitude, location.latitude);
}
if (heightOffset[groundName] === undefined) {
heightOffset[groundName] = 25;
}
const anchor = new BMap.Size(25, heightOffset[groundName]);
heightOffset[groundName] -= 50;
const iconImg = new BMap.Icon("./img/x2/" + team.team.altIds.opta + "@x2.png", new BMap.Size(50, 50), {anchor});
marker = new BMap.Marker(point, {icon: iconImg});
map.addOverlay(marker);
let deltax = -26;
if (name === UCL_title[season]) {
const uccImg = new BMap.Icon("img/trophy/ucl-trophy.svg", new BMap.Size(23, 35), {anchor: new BMap.Size(deltax, 15)});
const marker = new BMap.Marker(point, {icon: uccImg});
marker.setTitle(i18next.t("title." + UCL));
map.addOverlay(marker);
deltax -= 24;
(showTitleInfo)(marker, name, UCL);
document.getElementById("ucl").onclick = centerOnTeam;
document.getElementById("ucl").src = "img/trophy/ucl-trophy.svg";
}
if (name === PL_title[season]) {
const uccImg = new BMap.Icon("img/trophy/pl-trophy.svg", new BMap.Size(23, 35), {anchor: new BMap.Size(deltax, 15)});
const marker = new BMap.Marker(point, {icon: uccImg});
marker.setTitle(i18next.t("title." + PL));
map.addOverlay(marker);
deltax -= 24;
(showTitleInfo)(marker, name, PL);
document.getElementById("pl").onclick = centerOnTeam;
document.getElementById("pl").src = "img/trophy/pl-trophy.svg";
<!-- 改变地图配色 -->
<!-- $.getJSON(name+".json",function(styleJson){ -->
<!-- map.setMapStyle({styleJson:styleJson}); -->
<!-- }); -->
}
if (name === UEL_title[season]) {
const uccImg = new BMap.Icon("img/trophy/uel-trophy.svg", new BMap.Size(23, 35), {anchor: new BMap.Size(deltax, 15)});
const marker = new BMap.Marker(point, {icon: uccImg});
marker.setTitle(i18next.t("title." + UEL));
map.addOverlay(marker);
deltax -= 24;
(showTitleInfo)(marker, name, UEL);
document.getElementById("uel").onclick = centerOnTeam;
document.getElementById("uel").src = "img/trophy/uel-trophy.svg";
}
if (name === FA_final[season][0]) {
const uccImg = new BMap.Icon("img/trophy/fa-trophy.svg", new BMap.Size(23, 35), {anchor: new BMap.Size(deltax, 15)});
const marker = new BMap.Marker(point, {icon: uccImg});
marker.setTitle(i18next.t("title." + FA));
map.addOverlay(marker);
deltax -= 24;
(showTitleInfo)(marker, name, FA);
document.getElementById("fa").onclick = centerOnTeam;
document.getElementById("fa").src = "img/trophy/fa-trophy.svg";
}
if (name === EFL_final[season][0]) {
const uccImg = new BMap.Icon("img/trophy/efl-trophy.svg", new BMap.Size(23, 35), {anchor: new BMap.Size(deltax, 15)});
const marker = new BMap.Marker(point, {icon: uccImg});
marker.setTitle(i18next.t("title." + EFL));
map.addOverlay(marker);
deltax -= 24;
(showTitleInfo)(marker, name, EFL);
document.getElementById("efl").onclick = centerOnTeam;
document.getElementById("efl").src = "img/trophy/efl-trophy.svg";
}
if (CWC_final[season]!==undefined && name === CWC_final[season][0]) {
const uccImg = new BMap.Icon("img/trophy/cwc-trophy.svg", new BMap.Size(23, 35), {anchor: new BMap.Size(deltax, 15)});
const marker = new BMap.Marker(point, {icon: uccImg});
marker.setTitle(i18next.t("title." + CWC));
map.addOverlay(marker);
deltax -= 24;
(showTitleInfo)(marker, name, CWC);
document.getElementById("cwc").onclick = centerOnTeam;
document.getElementById("cwc").src = "img/trophy/cwc-trophy.svg";
}
if (name === FCWC_title[season]) {
const uccImg = new BMap.Icon("img/trophy/fcwc-trophy.svg", new BMap.Size(23, 35), {anchor: new BMap.Size(deltax, 15)});
const marker = new BMap.Marker(point, {icon: uccImg});
marker.setTitle(i18next.t("title." + FCWC));
map.addOverlay(marker);
deltax -= 24;
(showTitleInfo)(marker, name, FCWC);
document.getElementById("fcwc").onclick = centerOnTeam;
document.getElementById("fcwc").src = "img/trophy/fcwc-trophy.svg";
}
(function () {
marker.addEventListener("click", function () {
showInfo(this, team);
});
})();
});
}
//显示信息窗口,显示标注点的信息。
function showInfo(thisMarker, team) {
const name = team.team.name;
const position = team.position;
function isPromotion() {
return promotion[season].indexOf(name) >= 0;
}
function isDegradation() {
return (year === 1994 && position >= 19) || (year < 1994 && position >= 20) || (year > 1994 && position >= 18);
}
let pro_de_logo = '';
if (isPromotion() && isDegradation()) {
pro_de_logo = '<img id="promotion_and_degradation" src="img/promotion_and_degradation.svg" height="23px" title="' + i18next.t("other.promotion and degradation") + '" />';
} else if (isPromotion()) {
pro_de_logo = '<img id="promotion" src="img/promotion.svg" height="23px" title="' + i18next.t("other.promotion") + '" />';
} else if (isDegradation()) {
pro_de_logo = '<img id="degradation" src="img/degradation.svg" height="23px" title="' + i18next.t("other.degradation") + '"/>';
}
let pl_cnt = undefined;
if (PL_cnt[season] !== undefined) {
pl_cnt = PL_cnt[season][name];
}
if (pl_cnt === undefined) {
pl_cnt = "-";
}
let eplContent =
'<tr>'
+ '<th>' + i18next.t('other.' + "Premier League Title Count") + '</th>'
+ '<td>' + pl_cnt + '</td>'
+ '</tr>';
if (APL_latest[season][name] !== undefined) {
eplContent +=
'<tr>'
+ '<th>' + i18next.t('other.' + "Latest Premier League Title") + '</th>'
+ '<td>' + APL_latest[season][name] + '</td>'
+ '</tr>';
}
if (all_latest_all[name] !== undefined) {
eplContent +=
'<tr>'
+ '<th>' + i18next.t('other.' + "Latest Title") + '</th>'
+ '<td>' + all_latest_all[name].season+ " " + i18next.t('title.' + all_latest_all[name].title) + '</td>'
+ '</tr>';
}
let ucl_list = undefined;
if (UCL_list[season] !== undefined) {
ucl_list = UCL_list[season][name];
}
let uclContent = "";
if (ucl_list !== undefined) {
uclContent =
'<tr>'
+ '<th>' + i18next.t('other.' + "UCL Title") + "(" + ucl_list.length + "):" + '</th>'
+ '<td>' + ucl_list + '</td>'
+ '</tr>';
}
let uel_list = undefined;
if (UEL_list[season] !== undefined) {
uel_list = UEL_list[season][name];
}
let uelContent = "";
if (uel_list !== undefined) {
uelContent =
'<tr>'
+ '<th>' + i18next.t('other.' + "UEL Title") + "(" + uel_list.length + "):" + '</th>'
+ '<td>' + uel_list + '</td>'
+ '</tr>';
}
let cwc_list = undefined;
if (CWC_list[season] !== undefined) {
cwc_list = CWC_list[season][name];
} else {
cwc_list = CWC_list["1998-99"][name];
}
let cwcContent = "";
if (cwc_list !== undefined) {
cwcContent =
'<tr>'
+ '<th>' + i18next.t('other.' + "CWC Title") + "(" + cwc_list.length + "):" + '</th>'
+ '<td>' + cwc_list + '</td>'
+ '</tr>';
}
let derbyContent="";
if(derby[name]!==undefined){
let keys=Object.keys(derby[name]);
for(let i=0;i<keys.length;i++){
let derbyName=keys[i];
let rivals_list=[];
derby[name][derbyName].forEach((t,_1,_2)=>{
rivals_list.push(i18next.t(['team.'+t,"englandTeam."+t],t));
});
let rivals=rivals_list.join(',');
if(i===0){
derbyContent+=
'<tr class="separated">'
+ '<th>' +derbyName+":" + '</th>'
+ '<td>' + rivals + '</td>'
+ '</tr>';
}else{
derbyContent+=
'<tr>'
+ '<th>' +derbyName+":" + '</th>'
+ '<td>' + rivals + '</td>'
+ '</tr>';
}
}
}
let sContent =
'<h2>'
+ i18next.t('team.' + name)
+ pro_de_logo
+ '</h2>'
+ '<table border="0">'
+ '<tr>'
+ '<th>' + i18next.t('other.' + "Foundation") + '</th>'
+ '<td>' + foundation[name] + '</td>'
+ '</tr>'
+ '<tr>'
+ '<th>' + i18next.t('other.' + "Ground") + '</th>'
+ '<td>' + team.ground.name + '(' + team.ground.capacity + ')' + '</td>'
+ '</tr>'
+ '<tr>'
+ '<th>' + season + i18next.t('other.' + "Ranking") + '</th>'
+ '<td>' + team.position + '</td>'
+ '</tr>'
+ eplContent
+ uclContent
+ uelContent
+ cwcContent
+ derbyContent
+ '</table>';
let infoWindow = new BMap.InfoWindow(sContent, {enableMessage: false});// 创建信息窗口对象
thisMarker.openInfoWindow(infoWindow);//图片加载完毕重绘infowindow
}
})
}
</script>
</body>
</html>