1 | <?php
|
---|
2 | include_once('../global.php');
|
---|
3 |
|
---|
4 | class NetworkMap extends Page
|
---|
5 | {
|
---|
6 | var $FullTitle = 'Mapa sítě';
|
---|
7 | var $ShortTitle = 'Mapa sítě';
|
---|
8 | var $Load = 'initialize()';
|
---|
9 | var $Unload = 'GUnload()';
|
---|
10 |
|
---|
11 | function Show()
|
---|
12 | {
|
---|
13 | global $Config;
|
---|
14 | $Output = '<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key='.$Config['Web']['GoogleMapsApiKey'].'"
|
---|
15 | type="text/javascript">
|
---|
16 | </script>';
|
---|
17 | $Output .= '<script type="text/javascript">
|
---|
18 |
|
---|
19 | var map;
|
---|
20 | var tinyIcon;
|
---|
21 |
|
---|
22 | function initialize()
|
---|
23 | {
|
---|
24 | if (GBrowserIsCompatible())
|
---|
25 | {
|
---|
26 | map = new GMap2(document.getElementById("map_canvas"));
|
---|
27 | map.setMapType(G_SATELLITE_MAP);
|
---|
28 | map.setCenter(new GLatLng(49.260422, 18.081179), 15);
|
---|
29 | map.setUIToDefault();
|
---|
30 | map.addControl(new GOverviewMapControl(new GSize(128, 96)));
|
---|
31 |
|
---|
32 |
|
---|
33 | // Create our "tiny" marker icon
|
---|
34 | var tinyIcon = new GIcon();
|
---|
35 | tinyIcon.image = "point.gif";
|
---|
36 | tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
|
---|
37 | tinyIcon.iconSize = new GSize(10, 10);
|
---|
38 | tinyIcon.shadowSize = new GSize(10, 10);
|
---|
39 | tinyIcon.iconAnchor = new GPoint(5, 5);
|
---|
40 | tinyIcon.infoWindowAnchor = new GPoint(5, 1);';
|
---|
41 |
|
---|
42 | $Output .= '
|
---|
43 | }
|
---|
44 | }
|
---|
45 |
|
---|
46 | function toggleLabel(id)
|
---|
47 | {
|
---|
48 | var ele = document.getElementById(id);
|
---|
49 | ele.checked = !ele.checked;
|
---|
50 | ele.onclick( );
|
---|
51 | }
|
---|
52 |
|
---|
53 | function UpdateNetworkLinks()
|
---|
54 | {
|
---|
55 | if ((document.getElementById("NetworkLinks")).checked == true)
|
---|
56 | {
|
---|
57 | NetworkLinks = [';
|
---|
58 | $DbResult = $this->Database->query('SELECT * FROM NetworkLink WHERE Interface1 <> 0 AND Interface2 <> 0');
|
---|
59 | while($Link = $DbResult->fetch_assoc())
|
---|
60 | {
|
---|
61 | $DbResult2 = $this->Database->query('SELECT * FROM NetworkDevice WHERE NetworkDevice.Id = (SELECT Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface1'].')');
|
---|
62 | $DbResult3 = $this->Database->query('SELECT * FROM NetworkDevice WHERE NetworkDevice.Id = (SELECT Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface2'].')');
|
---|
63 | if(($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0))
|
---|
64 | {
|
---|
65 | $Device1 = $DbResult2->fetch_assoc();
|
---|
66 | $Device2 = $DbResult3->fetch_assoc();
|
---|
67 | if(($Device1['Used'] == 1) and ($Device2['Used'] == 1))
|
---|
68 | $Output .= 'new GPolyline([new GLatLng('.$Device1['PositionLatitude'].', '.$Device1['PositionLongitude'].'),new GLatLng('.$Device2['PositionLatitude'].', '.$Device2['PositionLongitude'].')], "#4F4FBF", 3, 0.8), ';
|
---|
69 | }
|
---|
70 | }
|
---|
71 | $Output .= '];
|
---|
72 | for (var i in NetworkLinks)
|
---|
73 | {
|
---|
74 | map.addOverlay(NetworkLinks[i]);
|
---|
75 | }
|
---|
76 |
|
---|
77 | } else { //checkbox turned off
|
---|
78 | for (var i in NetworkLinks)
|
---|
79 | {
|
---|
80 | map.removeOverlay(NetworkLinks[i]);
|
---|
81 | NetworkLinks[i] = null;
|
---|
82 | }
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | function toggleLabel(id)
|
---|
87 | {
|
---|
88 | var ele = document.getElementById(id);
|
---|
89 | ele.checked = !ele.checked;
|
---|
90 | ele.onclick( );
|
---|
91 | }
|
---|
92 |
|
---|
93 | function UpdateNetworkDevices()
|
---|
94 | {
|
---|
95 | if ((document.getElementById("NetworkDevices")).checked == true)
|
---|
96 | {
|
---|
97 | NetworkDevices = [';
|
---|
98 |
|
---|
99 | $DbResult = $this->Database->query('SELECT * FROM NetworkDevice WHERE Used=1');
|
---|
100 | while($Device = $DbResult->fetch_assoc())
|
---|
101 | {
|
---|
102 | $Output .= 'new GMarker(new GLatLng('.$Device['PositionLatitude'].', '.$Device['PositionLongitude'].'), {title: "'.$Device['Name'].'", icon:tinyIcon }), ';
|
---|
103 | }
|
---|
104 | $Output .= '];
|
---|
105 | for (var i in NetworkDevices)
|
---|
106 | {
|
---|
107 | map.addOverlay(NetworkDevices[i]);
|
---|
108 | }
|
---|
109 |
|
---|
110 | } else { //checkbox turned off
|
---|
111 | for (var i in NetworkDevices)
|
---|
112 | {
|
---|
113 | map.removeOverlay(NetworkDevices[i]);
|
---|
114 | NetworkDevices[i] = null;
|
---|
115 | }
|
---|
116 | }
|
---|
117 | }
|
---|
118 |
|
---|
119 | </script>';
|
---|
120 | $Output .= '<table style="margin-left: auto; margin-right: auto; width: 100%; height: 80%;">
|
---|
121 | <tr>
|
---|
122 | <td style="width: 80%; height: 100%;">
|
---|
123 | <div id="map_canvas" style="width: 100%; height: 100%;"></div></td>
|
---|
124 | <td style="width: 20%">
|
---|
125 | <form>
|
---|
126 | <input type="checkbox" id="NetworkLinks" onClick="UpdateNetworkLinks();" >
|
---|
127 | <a href="" onClick="toggleLabel(\'NetworkLinks\');return false;">Ukázat spoje</a>
|
---|
128 | </input><br />
|
---|
129 | <input type="checkbox" id="NetworkDevices" onClick="UpdateNetworkDevices();" >
|
---|
130 | <a href="" onClick="toggleLabel(\'NetworkDevices\');return false;">Ukázat zařízení</a>
|
---|
131 | </input>
|
---|
132 | </form></td>
|
---|
133 | </tr>
|
---|
134 | </table>';
|
---|
135 | return($Output);
|
---|
136 | }
|
---|
137 | }
|
---|
138 |
|
---|
139 | $System->AddModule(new NetworkMap());
|
---|
140 | $System->Modules['NetworkMap']->GetOutput();
|
---|
141 |
|
---|
142 | ?>
|
---|