-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapbox2.html
217 lines (173 loc) · 6.09 KB
/
mapbox2.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' /> <!-- Encoding -->
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.2/mapbox-gl.js'></script> <!-- Source: Mapbox GL JS -->
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.44.2/mapbox-gl.css' rel='stylesheet' /> <!-- Source: Add Mapbox CSS -->
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<style> <!-- Popup Style -->
/* Marker tweaks */
.mapboxgl-popup-close-button {
display: none;
}
.mapboxgl-popup-content {
font: 400 15px/18px 'Source Sans Pro', 'Helvetica Neue', Sans-serif;
padding: 0;
width: 180px;
}
.mapboxgl-popup-content-wrapper {
padding: 1%;
}
.mapboxgl-popup-content h3 {
background: #717171;
color: #fff;
margin: 0;
display: block;
padding: 10px;
border-radius: 3px 3px 0 0;
font-weight: 700;
margin-top: -15px;
}
.mapboxgl-popup-content h4 {
margin: 0;
display: block;
padding: 10px;
font-weight: 400;
}
.mapboxgl-popup-content div {
padding: 10px;
}
.mapboxgl-container .leaflet-marker-icon {
cursor: pointer;
}
.mapboxgl-popup-anchor-top > .mapboxgl-popup-content {
margin-top: 15px;
}
.mapboxgl-popup-anchor-top > .mapboxgl-popup-tip {
border-bottom-color: #91c949;
}
</style>
<style>
.legend {
background: rgba(255, 255, 255, 0.5);
border-radius: 3px;
border-style: solid;
border-width: 5px;
border-color: #1da1ab;
bottom: 30px;
box-shadow: 0 1px 2px rgba(0,0,0,0.10);
font: 12px/20px 'Helvetica Neue', Arial, Helvetica, sans-serif;
padding: 10px;
position: absolute;
right: 10px;
z-index: 1;
opacity = 0.5;
}
.legend h3 {
background: #808080;
color: #fff;
margin: +10px;
display: block;
padding: 10px;
width: 140px;
border-radius: 3px 3px 0 0;
font-size: large;
margin-top: -10px;
margin-right:-10px;
margin-left:-10px;
padding-left:5em;
}
.legend div span {
display:block;
float:left;
height:15px;
width:100%;
text-align:center;
font-size:12px;
background: rgba(255, 255, 255, 0.5);
}
</style>
<style>
#title {
position: absolute;
box-shadow: 0 1px 2px rgba(0,0,0,0.10);
border-radius: 3px;
opacity: 1;
top: 15px;
left: 20px;
width: 350px;
overflow: auto;
background: rgba(255, 255, 255, 0.5);
border-radius: 3px;
border-style: solid;
border-width: 5px;
border-color: #1da1ab;
font-family: "Arial";
padding-left: 20px;
padding-right: 20px;
padding-bottom: 15px;
border-radius: 3px;
}
</style>
<div id='state-legend' class='legend'>
<h3>Map Key</h3>
<div><span style='background: rgb(254, 229, 217, 0.7)'><b>Group Least Likely to Win<b/></span></div>
<div><span style='background: rgba(215, 48, 39, 0.7)'><b>2nd Group<b/></span></div>
<div><span style='background: rgba(252, 146, 114, 0.7)'><b>3rd Group<b/></span></div>
<div><span style='background: rgba(251, 107, 75, 0.7)'><b>4th Group<b/></span></div>
<div><span style='background: rgba(203, 24, 29, 0.7)'><b>5th Group<b/></span></div>
<div><span style='background: rgba(153, 0, 13, 0.7)'>6th Group<b/></span></div>
<div><span style='background: rgba(86, 1, 1, 0.7)'><b>Most Likely to Win<b/></span></div>
<small>Source: <a href="https://eeecon.uibk.ac.at/~zeileis/assets/posts/2018-05-30-fifa2018/fifa2018.csv">Forecasting FIFA World Cup Win</a></small>
</div>
<!-- Map ID -->
<div id='map'></div>
<!-- Geocoder ID -->
<div id='geocoder' class='geocoder'></div>
<div id='title'>
<h2>FIFA World Cup (2018) </h2>
<small>This interactive map shows the probability of each nation (who qualified), to win the tournemant. Here, darker shades of red represent nations that are more likely to win the tournemant, based off Leitner et al. (2010) bookmaker consensus model. This was successfully applied in previous football tournaments, e.g., correctly predicting the winner of the 2010 FIFA World Cup and three out of four semifinalists at the 2014 FIFA World Cup.</small>
<div id="tooltip-name"></div>
<div id='tooltip'></div>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoidGFzdGF0aGFtMSIsImEiOiJjamZ1ejY2bmYxNHZnMnhxbjEydW9sM29hIn0.w9ndNH49d91aeyvxSjKQqg'; //public access token
var map = new mapboxgl.Map({
container: 'map', //type of container
style: 'mapbox://styles/tastatham1/cjj45jp963p2u2sncikzrh38j', //user generated style from Mapbox
center: [-2.981979, 53.406315], // Set Zoom centre point
zoom: 3, // Sets automatic zoom
});
map.addControl(new mapboxgl.NavigationControl({ //Add navigation control - North Arrow
position: 'top-right' // position of navigation top-right
}));
map.addControl(new mapboxgl.FullscreenControl()); //Add full screen mode
map.addControl(new mapboxgl.ScaleControl({ //Add scale bar
maxWidth: 300,
unit: 'imperial'
}));
map.on('load', function () {
// When a click event occurs on a feature in the imddata layer, open p
map.on('click', 'worldcup2', function (e) {
new mapboxgl.Popup()
.setLngLat(e.lngLat)
.setHTML("<h3><b>Nation:</b> "+e.features[0].properties.Country + "</h3><h4><b>Semi Final:</b> "+e.features[0].properties.Semi + "</h4><h4><b>Final:</b> "+e.features[0].properties.Final + "</h4><h4><b>Win:</b> "+e.features[0].properties.Win + "</h4><h4><b>World Cup Wins:</b> "+e.features[0].properties.WC_wins + "</h4>")
.addTo(map);
});
// Change the cursor to a pointer when the mouse is over the states layer.
map.on('mouseenter', 'im1', function () {
map.getCanvas().style.cursor = 'pointer';
});
// Change it back to a pointer when it leaves.
map.on('mouseleave', 'worldcup2', function () {
map.getCanvas().style.cursor = '';
});
});
</script>
</body>
</html>