Changeset 864 for trunk/Modules/Map/Map.php
- Timestamp:
- Nov 10, 2019, 11:32:13 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Map/Map.php
r833 r864 8 8 var $ShortTitle = 'Mapa sítě'; 9 9 var $ParentClass = 'PagePortal'; 10 var $Load = 'initialize()';11 var $Unload = 'GUnload()';10 //var $Load = 'initialize()'; 11 //var $Unload = 'GUnload()'; 12 12 13 13 function Show() … … 30 30 $DbRow = $DbResult->fetch_assoc(); 31 31 $Pos = explode(';', $DbRow['Pos']); 32 $MapApi = new Map ApiGoogle($this->System);32 $MapApi = new MapOpenStreetMaps($this->System); 33 33 $MapApi->Position = array('Lat' => $Pos[0], 'Lng' => $Pos[1]); 34 34 $MapApi->Zoom = 18; 35 35 $MapApi->Key = $this->System->Config['Map']['GoogleMapsApiKey']; 36 36 $MapApi->ShowMarker = true; 37 $MapApi->MarkerText = $DbRow['Name']; 37 $Marker = new MapMarker(); 38 $Marker->Text = $DbRow['Name']; 39 $Marker->Position = $MapApi->Position; 40 $MapApi->Markers[] = $Marker; 38 41 $Output = $MapApi->ShowPage($this); 39 42 return($Output); … … 43 46 function ShowMain() 44 47 { 45 $Output = '<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key='. 46 $this->System->Config['Map']['GoogleMapsApiKey'].'" 47 type="text/javascript"> 48 </script>'; 49 $Output .= '<script type="text/javascript"> 50 51 var map; 52 var tinyIcon; 53 54 function initialize() 55 { 56 57 if (GBrowserIsCompatible()) 58 { 59 map = new GMap2(document.getElementById("map_canvas")); 60 map.setMapType(G_SATELLITE_MAP); 61 map.setCenter(new GLatLng(49.260422, 18.081179), 15); 62 map.setUIToDefault(); 63 map.addControl(new GOverviewMapControl(new GSize(128, 96))); 64 65 66 // Create our "tiny" marker icon 67 var tinyIcon = new GIcon(); 68 tinyIcon.image = "point.gif"; 69 tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; 70 tinyIcon.iconSize = new GSize(10, 10); 71 tinyIcon.shadowSize = new GSize(10, 10); 72 tinyIcon.iconAnchor = new GPoint(5, 5); 73 tinyIcon.infoWindowAnchor = new GPoint(5, 1); 74 75 toggleLabel(\'NetworkLinks\'); 76 toggleLabel(\'NetworkDevices\');'; 77 78 $Output .= ' 79 } 80 } 81 82 function toggleLabel(id) 83 { 84 var ele = document.getElementById(id); 85 ele.checked = !ele.checked; 86 ele.onclick( ); 87 } 88 89 function UpdateNetworkLinks() 90 { 91 if ((document.getElementById("NetworkLinks")).checked == true) 92 { 93 NetworkLinks = ['; 48 $Map = new MapOpenStreetMaps($this->System); 49 $Map->Position = array('Lat' => $this->System->Config['Map']['DefaultLatitude'], 50 'Lng' => $this->System->Config['Map']['DefaultLongitude']); 51 $Map->Zoom = $this->System->Config['Map']['DefaultZoom']; 52 $Map->Key = $this->System->Config['Map']['GoogleMapsApiKey']; 53 //$Map->OnClickObject = $_GET['r']; 54 //$MapApi->ShowMarker = true; 55 56 $DbResult = $this->Database->query('SELECT GROUP_CONCAT(`NetworkDevice`.`Name` SEPARATOR ",") AS `Name`, '. 57 '`MapPosition`.`Pos` AS `Pos`, `MapPosition`.`Name` AS `NodeName` '. 58 'FROM `NetworkDevice` LEFT JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 59 'WHERE (`NetworkDevice`.`Used`=1) AND (`NetworkDevice`.`MapPosition` IS NOT NULL) '. 60 'GROUP BY `NetworkDevice`.`MapPosition`'); 61 while($Device = $DbResult->fetch_assoc()) 62 { 63 $Pos = explode(';', $Device['Pos']); 64 $Marker = new MapMarker(); 65 $Marker->Position = array('Lat' => $Pos[0], 'Lng' => $Pos[1]); 66 $Marker->Text = $Device['NodeName'].': '.$Device['Name']; 67 $Map->Markers[] = $Marker; 68 } 69 94 70 $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)'); 95 71 while($Link = $DbResult->fetch_assoc()) … … 108 84 $Pos2 = explode(';', $Device2['Pos']); 109 85 if(($Device1['Used'] == 1) and ($Device2['Used'] == 1)) 110 $Output .= 'new GPolyline([new GLatLng('.$Pos1[0].', '. 111 $Pos1[1].'),new GLatLng('.$Pos2[0].', '.$Pos2[1].')], "#4F4FBF", 3, 0.8), '; 86 { 87 $PolyLine = new MapPolyLine(); 88 $PolyLine->Color = '#4F4FBF'; 89 $PolyLine->Points[] = array('Lat' => $Pos1[0], 'Lng' => $Pos1[1]); 90 $PolyLine->Points[] = array('Lat' => $Pos2[0], 'Lng' => $Pos2[1]); 91 $Map->PolyLines[] = $PolyLine; 92 } 93 } 94 } 95 96 $Output = $Map->ShowPage($this); 97 98 99 /* 100 $Output = '<script type="text/javascript" src="//maps.googleapis.com/maps/api/js?key='. 101 $this->System->Config['Map']['GoogleMapsApiKey'].'"></script>'; 102 $Output .= '<script type="text/javascript"> 103 104 var map; 105 var tinyIcon; 106 107 function initialize() 108 { 109 110 //if (google.maps.BrowserIsCompatible()) 111 { 112 map = new google.maps.Map(document.getElementById("map_canvas")); 113 map.setMapTypeId(\'satellite\'); 114 map.setCenter(new google.maps.LatLng(49.260422, 18.081179), 15); 115 //map.setUIToDefault(); 116 //map.addControl(new google.maps.OverviewMapControl(new google.maps.Size(128, 96))); 117 118 119 // Create our "tiny" marker icon 120 //var tinyIcon = new google.maps.Icon(); 121 //tinyIcon.image = "point.gif"; 122 //tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; 123 //tinyIcon.iconSize = new google.maps.Size(10, 10); 124 //tinyIcon.shadowSize = new google.maps.Size(10, 10); 125 //tinyIcon.iconAnchor = new google.maps.Point(5, 5); 126 //tinyIcon.infoWindowAnchor = new google.maps.Point(5, 1); 127 128 toggleLabel(\'NetworkLinks\'); 129 toggleLabel(\'NetworkDevices\');'; 130 131 $Output .= ' 132 } 133 } 134 135 function toggleLabel(id) 136 { 137 var ele = document.getElementById(id); 138 ele.checked = !ele.checked; 139 ele.onclick( ); 140 } 141 142 function UpdateNetworkLinks() 143 { 144 if ((document.getElementById("NetworkLinks")).checked == true) 145 { 146 NetworkLinks = ['; 147 $DbResult = $this->Database->query('SELECT * FROM `NetworkLink` WHERE (`Interface1` <> 0) AND (`Interface2` <> 0)'); 148 while($Link = $DbResult->fetch_assoc()) 149 { 150 $DbResult2 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '. 151 'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 152 'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface1'].')'); 153 $DbResult3 = $this->Database->query('SELECT `NetworkDevice`.`Used`, `MapPosition`.`Pos` FROM `NetworkDevice` '. 154 'JOIN `MapPosition` ON `MapPosition`.`Id` = `NetworkDevice`.`MapPosition` '. 155 'WHERE `NetworkDevice`.`Id` = (SELECT `NetworkInterface`.`Device` FROM `NetworkInterface` WHERE `NetworkInterface`.`Id` = '.$Link['Interface2'].')'); 156 if(($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0)) 157 { 158 $Device1 = $DbResult2->fetch_assoc(); 159 $Pos1 = explode(';', $Device1['Pos']); 160 $Device2 = $DbResult3->fetch_assoc(); 161 $Pos2 = explode(';', $Device2['Pos']); 162 if(($Device1['Used'] == 1) and ($Device2['Used'] == 1)) 163 $Output .= 'new google.maps.Polyline([new google.maps.LatLng('.$Pos1[0].', '. 164 $Pos1[1].'),new google.maps.LatLng('.$Pos2[0].', '.$Pos2[1].')], "#4F4FBF", 3, 0.8), '; 112 165 } 113 166 } … … 148 201 { 149 202 $Pos = explode(';', $Device['Pos']); 150 $Output .= 'new GMarker(new GLatLng('.$Pos[0].', '.151 $Pos[1].'), {title: "'.$Device['NodeName'].': '.$Device['Name'].'", icon: tinyIcon}), ';203 $Output .= 'new google.maps.Marker(new google.maps.LatLng('.$Pos[0].', '. 204 $Pos[1].'), {title: "'.$Device['NodeName'].': '.$Device['Name'].'", icon:\'point.gif\' }), '; 152 205 } 153 206 $Output .= ']; … … 182 235 </tr> 183 236 </table>'; 237 */ 184 238 return($Output); 185 239 }
Note:
See TracChangeset
for help on using the changeset viewer.