-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
77 lines (58 loc) · 2.03 KB
/
index.html
File metadata and controls
77 lines (58 loc) · 2.03 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
<!DOCTYPE html>
<html lang="en">
<head>
<title>Fonteine.</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" crossorigin=""></script>
<script src="https://cdn.jsdelivr.net/npm/leaflet.heat@0.2.0/dist/leaflet-heat.js" crossorigin=""></script>
<style>
body {
padding: 0;
margin: 0;
}
html, body, #map {
height: 100%;
width: 100vw;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
<div id="map"></div>
<script>
const map = L.map('map').setView([-28,23], 6);
const attribution = '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
const tileUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
const tiles = L.tileLayer(tileUrl, { attribution });
tiles.addTo(map);
let markers = [];
// data obtained from the dataset generated by Dirk Strauss https://dirkstrauss.com/south-african-cities/
async function loadData() {
const res1 = await fetch('./fonteine.json');
const res2 = await res1.json();
let heatpoints = [];
res2.forEach(i => {
let latLng = L.latLng([i.Latitude, i.Longitude]);
let point = map.latLngToContainerPoint(latLng);
let newPoint = L.point([point.x - 0, point.y - 0]);
let newLatLng = map.containerPointToLatLng(newPoint);
let marker = L.marker(newLatLng)
.bindTooltip(i.AccentCity)
.addTo(map);
markers.push(marker);
// add the heatmap points
heatpoints.push([i.Latitude, i.Longitude, 100]);
}); // finished iterating through list of points
//let heat = L.heatLayer(heatpoints, {radius: 20}).addTo(map);
}
/*
var heat = L.heatLayer([
[50.5, 30.5, 0.2], // lat, lng, intensity
[50.6, 30.4, 0.5]
], {radius: 25}).addTo(map);
*/
window.addEventListener("load", loadData, false);
</script>
</body>
</html>