-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparticipationMap.html
274 lines (219 loc) · 8.58 KB
/
participationMap.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
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Participation to the Liège Colloquium on Ocean Dynamics (1969 - 2018)</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.5.1/leaflet.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/1.4.3/Control.FullScreen.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.0.6/MarkerCluster.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.0.6/MarkerCluster.Default.css">
<style>
#map {height: 800px}
.info { padding: 6px 8px; font: 18px/20px Arial, Helvetica, sans-serif; background: white; background: rgba(255,255,255,0.8); font-size: 16px; box-shadow: 0 0 15px rgba(0,0,0,0.2); border-radius: 5px; }
.info h4 { margin: 0 0 5px; color: #777;font-size: 2em}
.legend { text-align: left; line-height: 18px; color: #555} .legend i { font-size: 2.5em; width: 18px; height: 18px; float: left; margin-right: 8px; opacity: 0.7; }
</style>
</head>
<body class="">
<div id="map" style="height:800px"></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.heat/0.2.0/leaflet-heat.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.fullscreen/1.4.3/Control.FullScreen.min.js"></script>
<script tupe="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.0.6/leaflet.markercluster.js"></script>
<script src="https://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="https://d3js.org/d3-hexbin.v0.2.min.js"></script>
<script type="text/javascript" src="../js/basemaps.js"></script>
<script type="text/javascript" src="../js/Leaflet.Geodesic.js"></script>
<script type="text/javascript" src="../js/leaflet-d3.min.js" charset="utf-8"></script>
<script type="text/javascript" src="data/Participants.coords"></script>
<script type="text/javascript" src="data/FrqParticipants.coords"></script>
<script type="text/javascript" src="data/DistParticipants.coords"></script>
<script type="text/javascript" src="data/ParticipantCountry1970-2017.geojson"></script>
<script>
var origin = L.latLng(50.5887, 5.8699);
var map = L.map('map',
{
fullscreenControl: true,
}
).setView([22., 0.], 3)
map.createPane('labels');
map.getPane('labels').style.zIndex = 650;
map.getPane('labels').style.pointerEvents = 'none';
var OpenStreetMap_BlackAndWhite = L.tileLayer('http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
});
var CartoDBLabels = L.tileLayer('http://{s}.basemaps.cartocdn.com/light_only_labels/{z}/{x}/{y}.png', {
attribution: '©OpenStreetMap, ©CartoDB',
pane: 'labels'
});
var CartoDBall = L.layerGroup([CartoDB, CartoDBLabels]);
Esri_OceanBasemap.addTo(map);
var baseMaps = {
"CartoDB": CartoDBall,
"OpenStreetMap": OpenStreetMap_Mapnik,
"OpenStreetMap B&W": OpenStreetMap_BlackAndWhite,
"ESRI Dark Grey Canvas": Esri_DarkGreyCanvas,
"ESRI Ocean Basemap": Esri_OceanBasemap
};
// control that shows state info on hover
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info');
this.update();
return this._div;
};
info.update = function (props) {
this._div.innerHTML = '<h4>Number of participants</h4>' + (props ?
'<b>' + props.name + ': </b>' + props.Participants
: '<b>Total: </b>' + "3309 from 71 countries");
};
info.addTo(map);
var geojson;
var GeodesicOptions = {
weight: 4,
opacity: .7,
color: '#00D118',
steps: 40,
};
var theLine = {};
function onClick(e) {
//if (theLine != undefined) {
// map.removeLayer(theLine);
//};
theLine = L.geodesic([[origin, this.getLatLng()]], GeodesicOptions).addTo(map);
}
// Extend the colormap (>25, >50?)
function getColor(d) {
return d >= 100 ? '#0c2c84' :
d > 50 ? '#225ea8' :
d > 10 ? '#1d91c0' :
d > 5 ? '#41b6c4' :
d > 1 ? '#7fcdbb' :
d > 0 ? '#ffff77' :
'#ffffff';
}
function style(feature) {
return {
fillColor: getColor(feature.properties.Participants),
weight: .5,
opacity: .7,
color: 'black',
fillOpacity: 0.8
};
}
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 2,
color: '#666',
dashArray: '',
fillOpacity: 0.5
});
if (!L.Browser.ie && !L.Browser.opera && !L.Browser.edge) {
layer.bringToFront();
}
info.update(layer.feature.properties);
}
function resetHighlight(e) {
geojson.resetStyle(e.target);
info.update();
}
function zoomToFeature(e) {
map.fitBounds(e.target.getBounds());
}
function onEachFeature(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
click: zoomToFeature
});
}
geojson = L.geoJson(participants, {
style: style,
onEachFeature: onEachFeature
}).addTo(map) ;
var legend = L.control({position: 'bottomright'});
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0, 1, 5, 10, 50, 100],
labels = ['<b># Participants</b>'],
from, to;
// 1st label is special case
labels.push('<i style="background:' + getColor(1) + '"></i> ' + '1');
for (var i = 1; i < grades.length -1 ; i++) {
from = grades[i] + 1;
to = grades[i + 1];
labels.push(
'<i style="background:' + getColor(from) + '"></i> ' +
from + (to ? '–' + to : '+'));
}
// Last label is special case
labels.push('<i style="background:' + getColor(grades[grades.length-1]) + '"></i> ' + 'More than ' + grades[grades.length-1]);
div.innerHTML = labels.join('<br>');
return div;
};
legend.addTo(map);
var heatStyle = {
gradient : {.65: "white", .75:"#FFFF36", .85:"#FF9D00", .9:"#FF1700", .95:"#900000", 1:"black"},
minOpacity: 0.95,
radius: 10,
blur: 10,
};
coordsPoints = coords.map(function (p) { return [p[0], p[1]]; });
coordsPointsHex = coords.map(function (p) { return [p[1], p[0]]; });
var markers = L.markerClusterGroup();
var circmarkers = L.layerGroup();
var circmarkersFrq = L.layerGroup();
var circmarkersDist = L.layerGroup();
for (var i = 0; i < coords.length; i++) {
var a = coords[i];
var marker = L.marker(new L.LatLng(a[0], a[1])).on('click', onClick);;
var circmarker = L.circleMarker(new L.LatLng(a[0], a[1]), {radius:1, color:"yellow"});
markers.addLayer(marker);
circmarkers.addLayer(circmarker);
}
//Add most frequent participants
for (var i = 0; i < coordsFrq.length; i++) {
var marker = L.circleMarker(new L.LatLng(coordsFrq[i][0], coordsFrq[i][1]),
{radius:7, color:"red"});
circmarkersFrq.addLayer(marker);
}
//Add largest-distance travelers
for (var i = 0; i < coordsDist.length; i++) {
var marker = L.circleMarker(new L.LatLng(coordsDist[i][0], coordsDist[i][1]),
{radius:7, color:GeodesicOptions["color"]});
var distLine = L.geodesic([[origin, coordsDist[i]]], GeodesicOptions);
circmarkersDist.addLayer(marker);
circmarkersDist.addLayer(distLine);
}
map.addLayer(circmarkers);
//map.addLayer(markers);
var heatmap = L.heatLayer(coordsPoints, heatStyle);
var hexoptions = {
radius : 15,
opacity: 0.6,
duration: 200,
colorScaleExtent: [ 1, 20 ],
radiusScaleExtent: [ 1, undefined ],
colorRange: ['#FFFFFF', '#F1FF67', '#FF8C00', '#FF2300'],
//colorValue: function(d) { return Math.sqrt(d.length); },
radiusRange: [ 10, 15],
};
var hexLayer = L.hexbinLayer(hexoptions);
hexLayer.data(coordsPointsHex);
//hexLayer.addTo(map);
var overlayers = {
"Choropleth map": geojson,
"Marker cluster": markers,
"Single dots": circmarkers,
"Heat map": heatmap,
"Hexbin": hexLayer,
"Most regular participants": circmarkersFrq,
"Longest trips": circmarkersDist
};
L.control.layers(baseMaps, overlayers, {autoZIndex:true, collapsed:true}).addTo(map);
</script>
</body></html>