-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.html
423 lines (389 loc) · 14.6 KB
/
map.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
<!DOCTYPE html>
<html>
<head>
<title>e</title>
<link
rel="apple-touch-icon"
sizes="180x180"
href="../images/apple-touch-icon.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="../images/favicon-32x32.png"
/>
<link
rel="icon"
type="image/png"
sizes="16x16"
href="../images/favicon-16x16.png"
/>
<link rel="manifest" href="/site.webmanifest" />
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Open%20Sans"
/>
<link
rel="stylesheet"
href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xodZBNTC5n17Xt2atTPuE1HxjVMSvLVW9ocqUKLsCC5CXdbqCmblAshOMAS6/keqq/sMZMZ19scR4PsZChSR7A=="
crossorigin=""
/>
<style>
body {
font-family: "Open Sans";
background-color: #36393f;
color: #ffffff;
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
}
.link {
color: #2f8aee;
}
.red {
color: red !important;
}
#map {
height: 100vh;
width: 99%;
margin-left: .5%;
margin-right: .5%;
}
#loading-overlay {
position: absolute;
height: 100%;
width: 99%;
margin-left: .5%;
margin-right: .5%;
background-color: rgba(255, 255, 255, 0.8);
display: flex;
justify-content: center;
align-items: center;
z-index: 10;
}
#loading-wheel {
border: 16px solid #2c3e50;
border-radius: 50%;
border-top: 16px solid #7f8c8d;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.toggle-container {
position: fixed;
top: 20px;
left: 20px;
background-color: rgba(54, 57, 63, 0.8);
padding: 10px;
border-radius: 5px;
color: #ffffff;
}
</style>
</head>
<body>
<script
src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""
></script>
<center>
<h1><strong>Benchmarks Map</strong></h1>
<p>
<a href="/benchmarks" class="link"
>Benchmarks</a>
<a href="/apps" class="link">Apps</a>
<a href="/" class="link">Home</a>
<a href="/gcstats" class="link"
>Geocaching Stats</a>
</p>
</center>
<hr />
<div id="loading-overlay">
<div id="loading-wheel"></div>
</div>
<div id="map"></div>
<script>
var azimuthGood = new L.Icon({
iconUrl:
"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-blue.png",
shadowUrl:
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});
var mainBad = new L.Icon({
iconUrl:
"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png",
shadowUrl:
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});
var refBad = new L.Icon({
iconUrl:
"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-yellow.png",
shadowUrl:
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});
var azimuthBad = new L.Icon({
iconUrl:
"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-orange.png",
shadowUrl:
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});
var none = new L.Icon({
iconUrl:
"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-black.png",
shadowUrl:
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});
var caltopo = L.tileLayer(
"https://caltopo.s3.amazonaws.com/topo/{z}/{x}/{y}.png",
{
attribution:
'© <a href="https://caltopo.com/map.html">Caltopo</a>',
maxNativeZoom: 16,
}
),
osm = L.tileLayer(
"https://tile.openstreetmap.org/{z}/{x}/{y}.png",
{
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
}
),
naip = L.tileLayer(
"https://naip.maptiles.arcgis.com/arcgis/rest/services/NAIP/MapServer/tile/{z}/{y}/{x}",
{
attribution:
"USDA-NAIP",
}
);
usgsImagery = L.tileLayer(
"https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}",
{
attribution:
"USDA-NAIP",
maxNativeZoom: 16
}
);
ersi = L.tileLayer(
"https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
{
attribution:
"Esri, Maxar, Earthstar Geographics, USDA FSA, USGS, Aerogrid, IGN, IGP, and the GIS User Community",
}
);
ersiClarity = L.tileLayer(
"https://clarity.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}",
{
attribution:
"Esri, DigitalGlobe, GeoEye, Earthstar Geographics, and the GIS User Community",
}
);
async function fetchJsonFiles() {
const folderUrl = "benchmarks\\json\\";
const files = [
'206.5.json', '6883.json', '6_MDC.json', 'A348_reset.json', 'A6_MDC.json', 'A77.json', 'ACE.json', 'altos.json', 'B19.json', 'baldy.json', 'bell2.json', 'big_wash.json', 'C884.json', 'cass.json', 'chiricaqua.json', 'city.json', 'clum.json', 'comstock.json', 'comstock_hill.json', 'curtis.json', 'del.json', 'E3.json', 'eare.json', 'F77.json', 'G87.json', 'G88.json', 'gila_butte.json', 'granite.json', 'griswold.json', 'H27-az.json', 'H27.json', 'H77.json', 'highway.json', 'indian.json', 'J27.json', 'juniper.json', 'K27.json', 'K32.json', 'L112.json', 'L295.json', 'L424.json', 'L88.json', 'la43.json', 'luces_point.json', 'ludi.json', 'M19.json', 'magnetic.json', 'mike.json', 'mule.json', 'N27.json', 'nogls1899.json', 'nogls1940.json', 'nogls2573.json', 'nogls2596_reset.json', 'nogls2835.json', 'nogls3140.json', 'nogls3290.json', 'nogls3531.json', 'nogls3653.json', 'nogls3721.json', 'nogls3891.json', 'nogls3969.json', 'nogls4040.json', 'nogls4200.json', 'nogls4503_reset.json', 'nogls4526.json', 'nogls4534.json', 'nogls4632.json', 'nogls4653.json', 'nogls4772.json', 'nogls4835.json', 'nogls4997.json', 'nogls5442.json', 'nogls5496.json', 'oro.json', 'pa2.json', 'pass-picacho.json', 'pass.json', 'prsct5346.json', 'prsct5557.json', 'purkiss.json', 'pusch.json', 'Q19.json', 'Q27.json', 'Q365.json', 'Q87.json', 'R27.json', 'R87.json', 'reserve.json', 'rolland.json', 'san.json', 'santa.json', 'sf200.json', 'sopori.json', 'sotol.json', 'stanford.json', 'strong.json', 'summerhaven.json', 'sutton.json', 'T20SR17ES24S25T20SR18ES19SC.json', 'T87.json', 'table.json', 'tamarack.json', 'tucson.json', 'tucson_camera.json', 'tucson_gravity.json', 'U27.json', 'U313.json', 'U340.json', 'U87.json', 'V19.json', 'V27.json', 'va8826.json', 'va9795.json', 'W2.json', 'wally.json', 'wasson.json', 'wolfe.json', 'Y18.json', 'Y19.json', 'Z18.json', 'Z419.json'
];
const data = [];
for (const file of files) {
const response = await fetch(folderUrl + file);
const json = await response.json();
data.push(json);
}
return data;
}
var mainGood = new L.Icon({
iconUrl:
"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-green.png",
shadowUrl:
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});
var refGood = new L.Icon({
iconUrl:
"https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-violet.png",
shadowUrl:
"https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png",
iconSize: [25, 41],
iconAnchor: [12, 41],
popupAnchor: [1, -34],
shadowSize: [41, 41],
});
var baseMaps = {
"Scanned USGS Topo Maps": caltopo,
OpenStreetMap: osm,
NAIP: naip,
"USGS Imagery": usgsImagery,
"Ersi World Imagery": ersi,
"Ersi Clarity": ersiClarity,
};
async function checkLinkExistence(url) {
return fetch(url)
.then(async response => {
try {
if (response.ok) {
return true
} else {
}
} catch (error) {
}
})
.catch(error => {
});
}
function createLink(url) {
return checkLinkExistence(url).then(exists => {
const link = document.createElement('a');
link.href = url;
link.target = '_blank';
if (!exists) {
link.classList.add('red');
link.textContent = 'Link not available';
} else {
link.textContent = 'More Info';
}
return link.outerHTML;
});
}
async function initializeMap(data) {
var map = L.map("map", {
center: [39.5, -98.7],
zoom: 5,
layers: osm,
});
L.control.layers(baseMaps).addTo(map);
await Promise.all(data.map(async point => {
const promises = [];
const mainLat = parseFloat(point.mainCoordLat);
const mainLong = parseFloat(point.mainCoordLong);
if (!isNaN(mainLat) && !isNaN(mainLong)) {
promises.push(
createLink(point.mainURL).then(mainURL => {
L.marker([mainLat, mainLong], {
icon: statusToIcon(point.mainStatus),
}).addTo(map)
.bindPopup(`<b>${point.mainName}</b><br>Status: ${point.mainStatus}<br>${mainURL}`);
})
);
}
for (let i = 1; i <= 6; i++) {
const refLat = parseFloat(point[`referenceCoordLat${i}`]);
const refLong = parseFloat(point[`referenceCoordLong${i}`]);
const refName = point[`referenceName${i}`];
const refStatus = point[`referenceStatus${i}`];
const refURL = point[`referenceURL${i}`];
if (!isNaN(refLat) && !isNaN(refLong) && refName !== 'n') {
promises.push(
createLink(refURL).then(refURL => {
L.marker([refLat, refLong], {
icon: statusToIcon(point[`referenceStatus${i}`]),
}).addTo(map)
.bindPopup(`<b>${refName}</b><br>Status: ${refStatus}<br>${refURL}`);
})
);
}
}
const azimuthLat = parseFloat(point.azimuthCoordLat);
const azimuthLong = parseFloat(point.azimuthCoordLong);
const azimuthName = point.azimuthName;
const azimuthStatus = point.azimuthStatus;
const azimuthURL = point.azimuthURL;
if (!isNaN(azimuthLat) && !isNaN(azimuthLong)) {
promises.push(
createLink(azimuthURL).then(azimuthURL => {
L.marker([azimuthLat, azimuthLong], {
icon: statusToIcon(point.azimuthStatus),
}).addTo(map)
.bindPopup(`<b>${azimuthName}</b><br>Status: ${azimuthStatus}<br>${azimuthURL}`);
})
);
}
await Promise.all(promises);
for (let i = 1; i <= 6; i++) {
const azimuthLat = parseFloat(point[`azimuthCoordLat${i}`]);
const azimuthLong = parseFloat(point[`azimuthCoordLong${i}`]);
const azimuthName = point[`azimuthName${i}`];
const azimuthStatus = point[`azimuthStatus${i}`];
const azimuthURL = point[`azimuthURL${i}`];
if (!isNaN(azimuthLat) && !isNaN(azimuthLong) && azimuthName !== 'n') {
promises.push(
createLink(azimuthURL).then(azimuthURL => {
L.marker([azimuthLat, azimuthLong], {
icon: statusToIcon(point[`azimuthStatus${i}`]),
}).addTo(map)
.bindPopup(`<b>${azimuthName}</b><br>Status: ${azimuthStatus}<br>${azimuthURL}`);
})
);
}
}
}));
document.getElementById('loading-overlay').style.display = 'none';
document.getElementById('loading-wheel').style.display = 'none';
}
function statusToIcon(status) {
if (status == "mainGood") {
return mainGood;
}
if (status == "mainBad") {
return mainBad;
}
if (status == "refGood") {
return refGood;
}
if (status == "refBad") {
return refBad;
}
if (status == "azimuthGood") {
return azimuthGood;
}
if (status == "azimuthBad") {
return azimuthBad;
}
if (status == "none") {
return none;
}
if (status == "n") {
return none;
}
console.log("Couldn't find a status!" + status)
}
document.addEventListener('DOMContentLoaded', async () => {
const data = await fetchJsonFiles();
initializeMap(data);
});
</script>
<div class="toggle-container">
<label for="toggle-background">Enable Glitter Background</label>
<input type="checkbox" id="toggle-background" onclick="toggleBackground()">
</div>
<script src="/files/glitter.js"></script>
</body>
</html>