-
Notifications
You must be signed in to change notification settings - Fork 1
/
map.html
67 lines (60 loc) · 2.55 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
<!DOCTYPE html>
<html>
<head>
<title>Find a way to join Yggdrasil network!</title>
<link rel="stylesheet" href="leaflet.css"/>
<script src="leaflet.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="screen.css" />
<link rel="stylesheet" href="MarkerCluster.css" />
<link rel="stylesheet" href="MarkerCluster.Default.css" />
<script src="leaflet.markercluster.js"></script>
</head>
<body>
<div id="map"></div>
<span>Mouse over a cluster to see the bounds of its children and click a cluster to zoom to those bounds</span>
<script type="text/javascript">
var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Points © 2019 Yggdrasil-network'
}),
latlng = L.latLng(55.753215, 37.622504);
var map = L.map('map', {center: latlng, zoom: 9, layers: [tiles]});
var markers = L.markerClusterGroup();
fetch('nodes.json').then(response => response.json()).then(
nodes => {
for (let [key, value] of Object.entries(nodes)) {
var title = value.physical.SSID;
var coord = value.physical.coord.split(', ');
var lastseen = new Date(value.lastseen * 1000);
var marker = L.marker(new L.LatLng(coord[0], coord[1]), { title: title });
var label = 'SSID: ' + value.physical.SSID + '<br \/>';
if (value.physical.hasOwnProperty('password') & value.physical.password !== '') {
label = label + 'Password: "'+value.physical.password+'"<br \/>';
}
if (value.physical.hasOwnProperty('mode') & value.physical.mode !== '') {
//TODO: сделать поподробнее
label = label + value.physical.mode+'<br \/>';
}
if (value.physical.hasOwnProperty('exconninfo') & value.physical.exconninfo !== '') {
label = label + value.physical.exconninfo + '<br \/>';
}
label = label +'<br \/>' + value.physical.description + '<br \/>' +'Last seen: '+ lastseen;
if (value.hasOwnProperty('contact') & value.contact !== '') {
if (typeof value.contact === "string"){
label = label +'<br \/>Contact: ' + value.contact;
}
if (typeof value.contact === "object" & value.contact.hasOwnProperty('email')){
label = label +'<br \/>Contact: ' + value.contact.email;
}
// TODO: другие формы контакта? Несколько емейлов?
}
marker.bindPopup(label);
markers.addLayer(marker);
}
}
)
map.addLayer(markers);
</script>
</body>
</html>