Changeset 864
- Timestamp:
- Nov 10, 2019, 11:32:13 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/IS/IS.php
r849 r864 456 456 } else $TabContent .= $this->ShowList($TypeItem['Table'], '`'. 457 457 $TypeItem['Ref'].'`='.$Id, $Item['Caption'], 458 $TypeItem['Ref'], $Id).'<br/>'; 458 $TypeItem['Ref'], $Id).'<br/>'; 459 459 } 460 460 $I++; … … 682 682 if(defined('NEW_PERMISSION') and !$this->System->User->CheckPermission($this->TableToModule($Table), 'Write')) 683 683 return('Nemáte oprávnění'); 684 $Map Api = new MapApiGoogle($this->System);685 $Map Api->Position = array('Lat' => $this->System->Config['Map']['DefaultLatitude'],684 $Map = new MapOpenStreetMaps($this->System); 685 $Map->Position = array('Lat' => $this->System->Config['Map']['DefaultLatitude'], 686 686 'Lng' => $this->System->Config['Map']['DefaultLongitude']); 687 $Map Api->Zoom = $this->System->Config['Map']['DefaultZoom'];688 $Map Api->Key = $this->System->Config['Map']['GoogleMapsApiKey'];689 $Map Api->OnClickObject = $_GET['r'];687 $Map->Zoom = $this->System->Config['Map']['DefaultZoom']; 688 $Map->Key = $this->System->Config['Map']['GoogleMapsApiKey']; 689 $Map->OnClickObject = $_GET['r']; 690 690 //$MapApi->ShowMarker = true; 691 $Output = $Map Api->ShowPage($this);691 $Output = $Map->ShowPage($this); 692 692 return($Output); 693 693 } -
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 } -
trunk/Modules/Map/MapAPI.php
r738 r864 1 1 <?php 2 2 3 class MapApi extends Model 3 class MapMarker 4 { 5 var $Position; 6 var $Text; 7 } 8 9 class MapPolyLine 10 { 11 var $Points = array(); 12 var $Color = 'black'; 13 } 14 15 class Map extends Model 4 16 { 5 17 var $Position; … … 7 19 var $Key; 8 20 var $OnClickObject; 9 var $ShowMarker;10 21 var $MarkerText; 22 var $Markers; 23 var $PolyLines; 11 24 12 25 function __construct($System) … … 17 30 $this->Key = ''; 18 31 $this->ShowMarker = false; 19 $this->MarkerText = ''; 32 $this->Markers = array(); 33 $this->PolyLines = array(); 34 $this->OnClickObject = null; 20 35 } 21 36 … … 26 41 } 27 42 28 class Map ApiGoogle extends MapApi43 class MapGoogle extends Map 29 44 { 30 45 function ShowPage($Page) 31 46 { 32 47 $Page->Load = 'initialize()'; 33 $Page->Unload = 'GUnload()';48 //$Page->Unload = 'google.maps.Unload()'; 34 49 $Page->BasicHTML = true; 35 50 $Page->HideMenu = true; 36 $Output = '<script src="http://maps.google.com/maps?file=api&v=2&sensor=true&key='. 37 $this->Key.'" 38 type="text/javascript"> 39 </script>'; 51 $Output = '<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key='.$this->Key.'"></script>'; 40 52 $Output .= '<script type="text/javascript"> 41 53 … … 45 57 function initialize() 46 58 { 47 if (GBrowserIsCompatible()) 59 60 61 //if (GBrowserIsCompatible()) 48 62 { 49 map = new GMap2(document.getElementById("map_canvas")); 50 map.setMapType(G_SATELLITE_MAP); 51 map.setCenter(new GLatLng('.$this->Position['Lat'].', '.$this->Position['Lng'].'), '.$this->Zoom.'); 52 map.setUIToDefault(); 53 map.addControl(new GOverviewMapControl(new GSize(128, 96))); 54 55 GEvent.addListener(map,"click",function(overlay, point) 63 map = new google.maps.Map(document.getElementById("map_canvas")); 64 map.center = {lat: 45.518, lng: -122.672}; 65 map.zoom = 18; 66 map.heading = 90; 67 map.tilt = 45; 68 map.mapTypeId = \'satellite\'; 69 map.zoom = '.$this->Zoom.'; 70 map.setCenter(new google.maps.LatLng('.$this->Position['Lat'].', '.$this->Position['Lng'].'), '.$this->Zoom.'); 71 //map.setUIToDefault(); 72 //map.addControl(new google.maps.OverviewMapControl(new google.maps.Size(128, 96))); 73 '; 74 if ($this->OnClickObject != null) 75 { 76 $Output .= 'google.maps.event.addListener(map,"click", function(overlay, point) 56 77 { 57 if (point) { 78 if (point) 79 { 58 80 set_return(point.lat() + ";" + point.lng(),"'.$this->OnClickObject.'"); 59 81 window.close(); 60 82 } 61 }); 62 } 83 });'; 84 } 85 $Output .= '}'; 63 86 64 87 // Create our "tiny" marker icon 65 var tinyIcon = new GIcon(); 66 tinyIcon.image = "'.$this->System->Link('/Modules/Map/point.gif').'"; 67 tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; 68 tinyIcon.iconSize = new GSize(10, 10); 69 tinyIcon.shadowSize = new GSize(10, 10); 70 tinyIcon.iconAnchor = new GPoint(5, 5); 71 tinyIcon.infoWindowAnchor = new GPoint(5, 1); 72 '; 88 //var tinyIcon = new google.maps.Icon(); 89 //tinyIcon.image = "'.$this->System->Link('/Modules/Map/point.gif').'"; 90 //tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; 91 //tinyIcon.iconSize = new google.maps.Size(10, 10); 92 //tinyIcon.shadowSize = new google.maps.Size(10, 10); 93 //tinyIcon.iconAnchor = new google.maps.Point(5, 5); 94 //tinyIcon.infoWindowAnchor = new google.maps.Point(5, 1); 73 95 74 if($this->ShowMarker) 75 $Output .= 'map.addOverlay(new GMarker(new GLatLng('.$this->Position['Lat'].', '. 76 $this->Position['Lng'].'), {title: "'.$this->MarkerText.'" }));'; 96 foreach ($this->Markers as $Marker) 97 { 98 $Output .= 'map.addOverlay(new google.maps.Marker(new google.maps.LatLng('.$Marker->Position['Lat'].', '. 99 $Marker->Position['Lng'].'), {title: "'.$Marker->Text.'" }));'; 100 } 77 101 $Output .= '} 78 102 </script>'; … … 82 106 } 83 107 84 class Map ApiSeznam extends MapApi108 class MapSeznam extends Map 85 109 { 86 110 87 111 } 112 113 class MapOpenStreetMaps extends Map 114 { 115 function GetPageHeader() 116 { 117 $Output = '<link rel="stylesheet" href="https://unpkg.com/leaflet@1.5.1/dist/leaflet.css" 118 integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" 119 crossorigin=""/>'; 120 $Output .= '<script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js" 121 integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==" 122 crossorigin=""></script>'; 123 return $Output; 124 } 125 126 function ShowPage($Page) 127 { 128 $this->System->PageHeaders[] = array($this, 'GetPageHeader'); 129 $Page->Load = 'initialize()'; 130 $Page->BasicHTML = true; 131 $Page->HideMenu = true; 132 $Output = '<script type="text/javascript"> 133 function initialize() 134 { 135 var mymap = L.map(\'mapid\').setView(['.$this->Position['Lat'].','.$this->Position['Lng'].'], '.$this->Zoom.'); 136 L.tileLayer(\'https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}\', { 137 attribution: \'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>\', 138 maxZoom: 18, 139 id: \'mapbox.streets\', 140 accessToken: \'pk.eyJ1IjoiY2hyb25vc2N6IiwiYSI6ImNrMnRqMzh3dTByM2czYnB2dnhnaWY0bjMifQ.ONeadi5sPjG5arnvfhxxGQ\' 141 }).addTo(mymap); 142 '; 143 144 foreach ($this->Markers as $Marker) 145 { 146 $Output .= 'var marker = L.marker(['.$Marker->Position['Lat'].', '.$Marker->Position['Lng'].'], { title: \''.$Marker->Text.'\'}).addTo(mymap); 147 '; 148 } 149 foreach ($this->PolyLines as $PolyLine) 150 { 151 $Points = array(); 152 foreach ($PolyLine->Points as $Point) 153 $Points[] = '['.$Point['Lat'].', '.$Point['Lng'].']'; 154 $Output .= 'var latlngs = ['.implode(', ', $Points).']; 155 var polyline = L.polyline(latlngs, {color: \'red\'}).addTo(mymap); 156 '; 157 } 158 if ($this->OnClickObject != null) 159 { 160 $Output .= 'function onMapClick(e) 161 { 162 if (e) 163 { 164 set_return(e.latlng.lat + ";" + e.latlng.lng,"'.$this->OnClickObject.'"); 165 window.close(); 166 } 167 } 168 mymap.on(\'click\', onMapClick);'; 169 } 170 $Output .= ' 171 } 172 </script>'; 173 $Output .= '<div id="mapid" style="width: 100%; height: 90%;"></div>'; 174 return $Output; 175 } 176 } -
trunk/Packages/Common/Error.php
r784 r864 63 63 } 64 64 65 function ExceptionHandler( Exception$Exception)65 function ExceptionHandler(Throwable $Exception) 66 66 { 67 67 $Backtrace = $Exception->getTrace();
Note:
See TracChangeset
for help on using the changeset viewer.