Changeset 209 for trunk/map/index.php
- Timestamp:
- May 6, 2009, 7:37:16 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/map/index.php
r4 r209 1 1 <?php 2 include_once('../style.php'); 3 ShowHeader('Mapa Zdìchova', 'Mapa', 'onload="load()" onunload="GUnload()"'); 4 ?> 5 6 <script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAc4xkN_94jkn2t2iN-ZATpxSU_LfcMbvQb2CfcG3YCVl7_yTkCRR3Ey664GMzlmT-I4dZ8VEShvo7Rw" 7 type="text/javascript"></script> 8 9 <script type="text/javascript"> 10 11 //<![CDATA[ 2 include_once('../global.php'); 12 3 13 function load() { 14 if (GBrowserIsCompatible()) { 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 function initialize() 20 { 21 if (GBrowserIsCompatible()) 22 { 23 var map = new GMap2(document.getElementById("map_canvas")); 24 map.setMapType(G_SATELLITE_MAP); 25 map.setCenter(new GLatLng(49.260422, 18.081179), 15); 26 map.setUIToDefault(); 27 28 // Create our "tiny" marker icon 29 var tinyIcon = new GIcon(); 30 tinyIcon.image = "point.gif"; 31 tinyIcon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png"; 32 tinyIcon.iconSize = new GSize(10, 10); 33 tinyIcon.shadowSize = new GSize(10, 10); 34 tinyIcon.iconAnchor = new GPoint(5, 5); 35 tinyIcon.infoWindowAnchor = new GPoint(5, 1); 36 37 // Set up our GMarkerOptions object literal 38 markerOptions = { icon:tinyIcon };'; 15 39 16 40 17 var map = new GMap(document.getElementById("map")); 18 map.addControl(new GLargeMapControl()); 19 map.addControl(new GScaleControl()); 20 //map.setCenter(new GLatLng(37.4419, -122.1419), 13); 21 22 function initArray() { 23 this.length = initArray.arguments.length; 24 for (var i = 0; i < this.length; i++) 25 this[i] = initArray.arguments[i]; 26 } 27 28 function from10toradix(value,radix){ 29 var retval = ''; 30 var ConvArray = new initArray(0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F'); 31 var intnum; 32 var tmpnum; 33 var i = 0; 34 35 intnum = parseInt(value,10); 36 if (isNaN(intnum)){ 37 retval = 'NaN'; 38 }else{ 39 while (intnum > 0.9){ 40 i++; 41 tmpnum = intnum; 42 // cancatinate return string with new digit: 43 retval = ConvArray[tmpnum % radix] + retval; 44 intnum = Math.floor(tmpnum / radix); 45 if (i > 100){ 46 // break infinite loops 47 retval = 'NaN'; 48 break; 49 } 50 } 41 $DbResult = $this->Database->query('SELECT * FROM NetworkDevice'); 42 while($Device = $DbResult->fetch_assoc()) 43 { 44 $Output .= 'map.addOverlay(new GMarker(new GLatLng('.$Device['PositionLatitude'].', '.$Device['PositionLongitude'].'), markerOptions)); '; 51 45 } 52 return retval; 53 } 54 55 // ============================================================ 56 // == We now have to write our own getTileUrl function ======== 57 CustomGetTileUrl=function(a,b) 46 47 $DbResult = $this->Database->query('SELECT * FROM NetworkLink WHERE Interface1 <> 0 AND Interface2 <> 0'); 48 while($Link = $DbResult->fetch_assoc()) 49 { 50 $DbResult2 = $this->Database->query('SELECT * FROM NetworkDevice WHERE NetworkDevice.Id = (SELECT Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface1'].')'); 51 $DbResult3 = $this->Database->query('SELECT * FROM NetworkDevice WHERE NetworkDevice.Id = (SELECT Device FROM NetworkInterface WHERE NetworkInterface.Id = '.$Link['Interface2'].')'); 52 if(($DbResult2->num_rows > 0) and ($DbResult3->num_rows > 0)) 58 53 { 59 60 k = Math.pow(2, (b-5)) - 1; 61 62 b = b-2; 63 var c=Math.pow(2, (28-b)); 64 var x = from10toradix((a.x+1)* c - 0x1c000000, 16); 65 var y = from10toradix(0x1c000000 - (a.y-k) * c, 16); 66 return "http://mapserver.mapy.cz/ophoto/"+b+"_"+x+"_"+y+""; 54 $Device1 = $DbResult2->fetch_assoc(); 55 $Device2 = $DbResult3->fetch_assoc(); 56 $Output .= 'map.addOverlay(new GPolyline([new GLatLng('.$Device1['PositionLatitude'].', '.$Device1['PositionLongitude'].'),new GLatLng('.$Device2['PositionLatitude'].', '.$Device2['PositionLongitude'].')], "#FFFFFF", 3, 0.8)); '; 67 57 } 68 69 // ============================================================70 // ====== Create a single layer "Old OSS" custom maptype ======71 //72 // == Create the GTileLayer ==73 var tilelayers = [new GTileLayer(new GCopyrightCollection(""),5,18)];74 tilelayers[0].getTileUrl = CustomGetTileUrl;75 tilelayers[0].getCopyright = function(a,b) {76 return {prefix:"Mapové podklady: ", copyrightTexts:[" GEODIS BRNO, s.r.o."]};77 }78 79 // == Create the GMapType, copying most things from G_SATELLITE_MAP ==80 var custommap = new GMapType(tilelayers, G_SATELLITE_MAP.getProjection(), "Letecká",{errorMessage:_mMapError});81 82 // == Add the maptype to the map ==83 map.addMapType(custommap);84 85 // ============================================================86 // ====== Create a two layer "OSS Hybrid" layer ==============87 88 // === It has two layers one is the "Old OSS" map and the other is the top layer from G_HYBRID_MAP89 var htilelayers = [90 tilelayers[0], // a reference to the tile layer from the first custom map91 G_HYBRID_MAP.getTileLayers()[1] // a reference to the upper tile layer fo the hybrid map92 ];93 94 var custommap2 = new GMapType(htilelayers, G_SATELLITE_MAP.getProjection(), "Letecká+", {maxResolution:18,minResolution:1,errorMessage:_mMapError});95 96 // === Add it to the list of map types ===97 map.addMapType(custommap2);98 99 // ============================================================100 map.addControl(new GMapTypeControl());101 102 map.setCenter(new GLatLng(47.5172, 14.5019), 5, custommap);103 104 GEvent.addListener(map, "moveend", function() {105 var center = map.getCenter();106 var b = map.getZoom();107 var a = map.getCenter();108 document.getElementById("message").innerHTML = center.toString() + CustomGetTileUrl(a, b) + " "+(b-5);109 });110 }111 112 // display a warning if the browser was not compatible113 else {114 alert("Sorry, the Google Maps API is not compatible with this browser");115 58 } 116 117 // This Javascript is based on code provided by the 118 // Blackpool Community Church Javascript Team 119 // http://www.commchurch.freeserve.co.uk/ 120 // http://www.econym.demon.co.uk/googlemaps/ 121 59 $Output .= ' 60 } 122 61 } 123 124 //]]> 125 </script> 126 <div align="center"> 127 <div id="map" style="width: 800px; height: 500px"></div> 62 </script>'; 63 $Output .= '<div align="center"> 64 <div id="map_canvas" style="width: 800px; height: 500px;"></div> 128 65 <div id="message"></div> 129 66 <div id="message2"></div> 130 </div> 67 </div>'; 68 return($Output); 69 } 70 } 131 71 132 <?php 133 ShowFooter(); 72 $System->AddModule(new NetworkMap()); 73 $System->Modules['NetworkMap']->GetOutput(); 74 134 75 ?>
Note:
See TracChangeset
for help on using the changeset viewer.