This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.php
95 lines (80 loc) · 2.37 KB
/
map.php
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
<?php
header('Content-Type: text/html; charset=utf-8');
require 'config.php';
require 'lib/simpleCachedCurl.inc.php';
require 'lib/datafetcher.php';
$routerList = array();
foreach($communities AS $communityKey => $community)
{
// query api, get simplexml
$xml = getXml($community['url']);
if(!$xml)
{
return;
}
$routers = $xml->routerlist->router;
if(!$routers)
{
return;
}
foreach($routers AS $router)
{
if($router->latitude == '0' || $router->longitude == '0')
{
// router has no location
continue;
}
$thisRouter = array(
'id' => (int)$router->router_id,
'lat' => (string)$router->latitude,
'long' => (string)$router->longitude,
'name' => (string)$router->hostname,
'community' => $communityKey,
'status' => (string)$router->statusdata->status,
'clients' => (int)$router->statusdata->client_count,
'user' => array('id' => (int)$router->user->user_id, 'name' => (string)$router->user->nickname)
);
// add to routerlist for later use in JS
array_push($routerList, $thisRouter);
}
}
?>
<html>
<head>
<link href="<?php echo $localNetmon;?>templates/freifunk_oldenburg/css/central_netmon.css" rel="stylesheet" type="text/css"/>
<link rel="stylesheet" href="css/site.css" />
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="js/leaflet.markercluster-src.js"></script>
<link rel="stylesheet" href="css/MarkerCluster.Default.css" />
<link rel="stylesheet" href="css/MarkerCluster.css" />
<script src="js/meta_map.js"></script>
<style>
html{
height:100%;
overflow: hidden;
}
body {
height:99%;
padding: 10px;
box-sizing: border-box;
}
</style>
</head>
<body>
<div id="map"></div>
<a class="btn" href="index.php" id="toList">zur Liste</a>
<script>
var allTheRouters = <?php echo json_encode($routerList);?>;
var communities = <?php echo json_encode($communities);?>;
var tileServerUrl = <?php echo json_encode($tileServerUrl);?>;
var tileServerAttribution = <?php echo json_encode($tileServerAttribution);?>;
var mapInitalView = <?php echo json_encode($mapInitalView);?>;
$(function() {
// initialize cluster, add points
addPoints2Map(allTheRouters);
});
</script>
</body>
</html>