Changeset 574 for trunk/Modules/Map/Map.php
- Timestamp:
- Sep 29, 2013, 2:38:34 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Map/Map.php
r566 r574 1 1 <?php 2 2 3 include_once(dirname(__FILE__).'/ ../../Common/Global.php');3 include_once(dirname(__FILE__).'/MapAPI.php'); 4 4 5 5 class PageNetworkMap extends Page … … 15 15 if(count($this->System->PathItems) > 1) 16 16 { 17 if($this->System->PathItems[1] == 'show-position') 18 { 19 $DbResult = $this->Database->select('MapPosition', '*', 'Id='.$_GET['i']); 20 if($DbResult->num_rows > 0) 21 { 22 $DbRow = $DbResult->fetch_assoc(); 23 Header('Location: http://www.mapy.cz/#!x='.$DbRow['Longitude'].'&y='. 24 $DbRow['Latitude'].'&z=17&t=s&l=15&d=user_'.$DbRow['Longitude'].'%2C'. 25 $DbRow['Latitude'].'%2C'.$DbRow['Name'].'~%0A_1'); 26 return('Přesměrování na http://www.mapy.cz/'); 27 } else return('Položka nenalezena'); 28 return(''); 29 } 17 if($this->System->PathItems[1] == 'show-position') return($this->ShowPosition()); 30 18 else return(PAGE_NOT_FOUND); 31 19 } else return($this->ShowMain()); 32 20 } 33 21 22 function ShowPosition() 23 { 24 $DbResult = $this->Database->select('MapPosition', '*', 'Id='.$_GET['i']); 25 if($DbResult->num_rows > 0) 26 { 27 $DbRow = $DbResult->fetch_assoc(); 28 $Pos = explode(';', $DbRow['Pos']); 29 $MapApi = new MapApiGoogle($this->System); 30 $MapApi->Position = array('Lat' => $Pos[0], 'Lng' => $Pos[1]); 31 $MapApi->Zoom = 18; 32 $MapApi->Key = $this->System->Config['Map']['GoogleMapsApiKey']; 33 $MapApi->ShowMarker = true; 34 $MapApi->MarkerText = $DbRow['Name']; 35 $Output = $MapApi->ShowPage($this); 36 return($Output); 37 } else return('Položka nenalezena'); 38 } 39 34 40 function ShowMain() 35 41 { 36 $Output = '<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key='.$this->System->Config['Web']['GoogleMapsApiKey'].'" 42 $Output = '<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key='. 43 $this->System->Config['Map']['GoogleMapsApiKey'].'" 37 44 type="text/javascript"> 38 45 </script>'; … … 60 67 tinyIcon.shadowSize = new GSize(10, 10); 61 68 tinyIcon.iconAnchor = new GPoint(5, 5); 62 tinyIcon.infoWindowAnchor = new GPoint(5, 1);'; 63 64 $Output .= ' 69 tinyIcon.infoWindowAnchor = new GPoint(5, 1); 70 71 toggleLabel(\'NetworkLinks\'); 72 toggleLabel(\'NetworkDevices\');'; 73 74 $Output .= ' 65 75 } 66 76 } … … 81 91 while($Link = $DbResult->fetch_assoc()) 82 92 { 83 $DbResult2 = $this->Database->query('SELECT NetworkDevice.Used, MapPosition.Latitude, MapPosition.Longitude FROM NetworkDevice JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition WHERE NetworkDevice.Id = (SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface1'].')'); 84 $DbResult3 = $this->Database->query('SELECT NetworkDevice.Used, MapPosition.Latitude, MapPosition.Longitude FROM NetworkDevice JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition WHERE NetworkDevice.Id = (SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface2'].')'); 93 $DbResult2 = $this->Database->query('SELECT NetworkDevice.Used, MapPosition.Pos FROM NetworkDevice '. 94 'JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition '. 95 'WHERE NetworkDevice.Id = (SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface1'].')'); 96 $DbResult3 = $this->Database->query('SELECT NetworkDevice.Used, MapPosition.Pos FROM NetworkDevice '. 97 'JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition '. 98 'WHERE NetworkDevice.Id = (SELECT NetworkInterface.Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface2'].')'); 85 99 if(($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0)) 86 100 { 87 101 $Device1 = $DbResult2->fetch_assoc(); 102 $Pos1 = explode(';', $Device1['Pos']); 88 103 $Device2 = $DbResult3->fetch_assoc(); 104 $Pos2 = explode(';', $Device2['Pos']); 89 105 if(($Device1['Used'] == 1) and ($Device2['Used'] == 1)) 90 $Output .= 'new GPolyline([new GLatLng('.$Device1['Latitude'].', '.$Device1['Longitude'].'),new GLatLng('.$Device2['Latitude'].', '.$Device2['Longitude'].')], "#4F4FBF", 3, 0.8), '; 106 $Output .= 'new GPolyline([new GLatLng('.$Pos1[0].', '. 107 $Pos1[1].'),new GLatLng('.$Pos2[0].', '.$Pos2[1].')], "#4F4FBF", 3, 0.8), '; 91 108 } 92 109 } … … 120 137 121 138 $DbResult = $this->Database->query('SELECT GROUP_CONCAT(NetworkDevice.Name SEPARATOR ",") AS Name, '. 122 'MapPosition. Latitude AS Latitude, MapPosition.Longitude AS Longitude, MapPosition.Name AS NodeName '.139 'MapPosition.Pos AS Pos, MapPosition.Name AS NodeName '. 123 140 'FROM NetworkDevice LEFT JOIN MapPosition ON MapPosition.Id = NetworkDevice.MapPosition '. 124 141 'WHERE (NetworkDevice.Used=1) AND (NetworkDevice.MapPosition IS NOT NULL) '. … … 126 143 while($Device = $DbResult->fetch_assoc()) 127 144 { 128 $Output .= 'new GMarker(new GLatLng('.$Device['Latitude'].', '. 129 $Device['Longitude'].'), {title: "'.$Device['NodeName'].': '.$Device['Name'].'", icon:tinyIcon }), '; 145 $Pos = explode(';', $Device['Pos']); 146 $Output .= 'new GMarker(new GLatLng('.$Pos[0].', '. 147 $Pos[1].'), {title: "'.$Device['NodeName'].': '.$Device['Name'].'", icon:tinyIcon }), '; 130 148 } 131 149 $Output .= ']; … … 141 159 NetworkDevices[i] = null; 142 160 } 143 } 161 } 144 162 } 145 163 … … 151 169 <td style="width: 20%"> 152 170 <form> 153 <input type="checkbox" id="NetworkLinks" onClick="UpdateNetworkLinks();" 171 <input type="checkbox" id="NetworkLinks" onClick="UpdateNetworkLinks();"> 154 172 <a href="" onClick="toggleLabel(\'NetworkLinks\');return false;">Ukázat spoje</a> 155 173 </input><br /> 156 <input type="checkbox" id="NetworkDevices" onClick="UpdateNetworkDevices();" 174 <input type="checkbox" id="NetworkDevices" onClick="UpdateNetworkDevices();"> 157 175 <a href="" onClick="toggleLabel(\'NetworkDevices\');return false;">Ukázat zařízení</a> 158 176 </input> … … 160 178 </tr> 161 179 </table>'; 180 return($Output); 181 } 182 } 183 184 class TypeMapPosition extends TypeString 185 { 186 function OnEdit($Item) 187 { 188 $Output = parent::OnEdit($Item); 189 if($this->FormManager->ShowRelation) 190 $Output .= '<img src="'.$this->FormManager->Root.'/images/select.png" alf="Vybrat" language="javascript" '. 191 'onclick="return popupwindow("'.$this->FormManager->Root.'/is/?a=mapselect&r='. 192 $Item['Name'].'","test");" style="cursor:hand;cursor:pointer"/>'; 162 193 return($Output); 163 194 } … … 182 213 parent::Start(); 183 214 $this->System->Pages['map'] = 'PageNetworkMap'; 215 $this->System->FormManager->Type->RegisterType('MapPosition', 'String', array()); 184 216 $this->System->FormManager->RegisterClass('MapPosition', array( 185 217 'Title' => 'Pozice na mapě', … … 187 219 'Items' => array( 188 220 'Name' => array('Type' => 'String', 'Caption' => 'Jméno', 'Default' => ''), 189 'Latitude' => array('Type' => 'Float', 'Caption' => 'Zeměpisná šířka', 'Default' => '0'), 190 'Longitude' => array('Type' => 'Float', 'Caption' => 'Zeměpisná výška', 'Default' => '0'), 221 'Pos' => array('Type' => 'MapPosition', 'Caption' => 'Poloha', 'Default' => '0;0'), 191 222 ), 192 223 'ItemActions' => array(
Note:
See TracChangeset
for help on using the changeset viewer.