forked from Enecuum/explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.html
62 lines (62 loc) · 1.98 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link href="assets/css/vendor/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css" />
<link href="assets/css/app-dark.min.css" rel="stylesheet" type="text/css" />
<!-- angularJS scripts -->
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</head>
<body>
<div class="pb-2 text-center">
<h4 class="d-inline header-title">Total Nodes: </h4>
<h4 class="d-inline " id="nodeCount"></h4>
</div>
<div id="world-map-markers" style="height: 410px"></div>
<!-- scripts for widgets -->
<script src="assets/js/vendor/jquery-jvectormap-1.2.2.min.js" ></script>
<script src="assets/js/vendor/jquery-jvectormap-world-mill-en.js" ></script>
<script type="text/javascript">
$(document).ready(function() {
var settings = {
"async": true,
"crossDomain": true,
"url": "/api/v1/peer_map",
"method": "GET"
};
$.ajax(settings).done(function (response) {
let nodesCount = 0;
let marker_style = [{r: 5, fill: 'black'}, {r: 5, fill: 'blue'}, {r: 5, fill: 'red'}, {r: 5, fill: 'green'}];
let markers = response.filter((el) => (el.lat !== null && el.lon !== null))
.map((el) => {
nodesCount += el.count;
return {latLng: [el.lat, el.lon], name: el.count.toString(), style: marker_style[el.type]}
});
$(function () {
$("#nodeCount").text(nodesCount)
$("#world-map-markers").vectorMap({
map: "world_mill_en", normalizeFunction: "polynomial", hoverOpacity: .7, hoverColor: !1, regionStyle: {
initial: {fill: "#e3eaef"}
},
markerStyle: {
initial: {
r: 9,
fill: "#727cf5",
"fill-opacity": .9,
stroke: "#fff",
"stroke-width": 7,
"stroke-opacity": .4
},
hover: {
stroke: "#fff", "fill-opacity": 1, "stroke-width": 1.5
}
},
backgroundColor: "transparent",
markers: markers
});
});
});
});
</script>
</body>
</html>