diff options
author | Othmar Gsenger <otti@ffgraz.net> | 2013-11-12 18:24:00 +0000 |
---|---|---|
committer | Othmar Gsenger <otti@ffgraz.net> | 2013-11-12 18:24:00 +0000 |
commit | a47c4eecff79c1d57650b46c437b628d873705b2 (patch) | |
tree | 9d53fe963419ce8965fe237be47784c1afd84510 /map.js | |
parent | f6be9edd401664d95e60ae3c81aeaf36723ba891 (diff) |
bisher uncommitete aenderungen am www.ffgraz.net (nicht von mir)
Diffstat (limited to 'map.js')
-rw-r--r-- | map.js | 264 |
1 files changed, 246 insertions, 18 deletions
@@ -1,10 +1,11 @@ var map = null; +var linkinfo; var physicalMaxLevel; var geocoder = null; var reloadcon = null; var countboxText = null; var overlays = new Array(); -overlays["newmarker"] = null; +overlays["new"] = null; overlays["ruler"] = new Array(); overlays["locations"] = new Array(); overlays["links"] = new Array(); @@ -21,10 +22,25 @@ function initialize(lat, lng, res) { map.disableDoubleClickZoom(); map.enableScrollWheelZoom(); - map.removeMapType(G_HYBRID_MAP); - map.removeMapType(G_SATELLITE_MAP); +// map.removeMapType(G_HYBRID_MAP); +// map.removeMapType(G_SATELLITE_MAP); map.addMapType(G_PHYSICAL_MAP); - map.setMapType(G_PHYSICAL_MAP); +// map.setMapType(G_HYBRID_MAP); + + // openStreetMap + var copyOSM = new GCopyrightCollection("<a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a>"); + var copyOGDGraz = new GCopyrightCollection("Open Government Data Graz"); + copyOSM.addCopyright(new GCopyright(1, new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)), 0, " ")); + var tilesOsmarender = new GTileLayer(copyOSM, 1, 17, {tileUrlTemplate: 'http://tah.openstreetmap.org/Tiles/tile/{Z}/{X}/{Y}.png'}); + var mapOsmarender = new GMapType([tilesOsmarender], G_NORMAL_MAP.getProjection(), "openSM", {urlArg: 'y'}); + map.addMapType(mapOsmarender); + var tilesMapnik = new GTileLayer(copyOSM, 1, 17, {tileUrlTemplate: 'http://tile.openstreetmap.org/{Z}/{X}/{Y}.png'}); + var mapMapnik = new GMapType([tilesMapnik], G_NORMAL_MAP.getProjection(), "Mapnik", {urlArg: 'x'}); + map.addMapType(mapMapnik); +// var tilesOpenGeoServer = new GTileLayer(copyOGDGraz, 1, 17, {tileUrlTemplate: 'http://services.opengeoserver.org/tiles/1.0.0/globe.aerial_EPSG3857/${Z}/${X}/${Y}.png?origin=nw'}); +// var mapOpenGeoServer = new GMapType([tilesOpenGeoServer], G_NORMAL_MAP.getProjection(), "OpenGeoServer"); +// map.addMapType(mapOpenGeoServer); + physicalMaxLevel = map.getCurrentMapType().getMaximumResolution(); if(res > physicalMaxLevel) { map.setMapType(G_NORMAL_MAP); @@ -39,11 +55,19 @@ function initialize(lat, lng, res) { GEvent.addListener(map, "addoverlay", onAddOverlay); GEvent.addListener(map, "zoomend", onZoom); GEvent.addListener(map, "click", onMapClick); - + + lineinfo = document.createElement("div"); + document.getElementById("map").appendChild(lineinfo); + lineinfo.style.visibility = "hidden" + + dnsinfo = document.createElement("div"); + document.getElementById("map").appendChild(dnsinfo); + dnsinfo.style.visibility = "hidden" + var mt = map.getMapTypes(); for (var i=0; i<mt.length; i++) { mt[i].getMinimumResolution = function() {return 0;} - mt[i].getMaximumResolution = function() {return 17;} + mt[i].getMaximumResolution = function() {return 22;} } geocoder = new GClientGeocoder(); @@ -72,7 +96,7 @@ function onAddOverlay(overlay) { switch(overlay.overlaytype) { case "location": overlays["locations"].push(overlay); break; case "link": overlays["links"].push(overlay); break; - case "newmarker": { + case "new": { if(overlays["newmarker"]) { map.removeOverlay(overlays["newmarker"]); } @@ -92,13 +116,14 @@ function onAddOverlay(overlay) { function onZoom(oldLevel, newLevel) { if(newLevel > physicalMaxLevel) { - map.setMapType(G_NORMAL_MAP); + // map.setMapType(G_SATELLITE_MAP); } } function onMapClick(overlay, point) { if(!overlay) { + map.setCenter(point); setNewMarker(point); } } @@ -162,6 +187,7 @@ function Location(element) { location.pixel_y = parseInt(element.getAttribute("pixel_y")); location.state = element.getAttribute("state"); location.gallery_link = element.getAttribute("gallery_link"); + location.dnsnames = element.getAttribute("router_links"); return location; } @@ -172,18 +198,64 @@ function onLocationClick(latlng) { html += '<table class="locinfo">'; html += '<tr><td>Breitengrad:</td><td> </td><td>' + convertCoords(locations[this.locid].point.lat()) + '</td></tr>'; html += '<tr><td>Längengrad:</td><td> </td><td>' + convertCoords(locations[this.locid].point.lng()) + '</td></tr>'; - html += '<tr><td>Datenbank:</td><td> </td><td><a href="http://manman.graz.funkfeuer.at/location/show/' + this.locid + '">Link</td></tr>'; - html += '<tr><td>Smokeping:</td><td> </td><td><a href="http://www.graz.funkfeuer.at/cgi-bin/smokeping.cgi?target=FunkFeuer.' + locations[this.locid].name + '">Link</td></tr>'; + html += '<tr><td>Datenbank:</td><td> </td><td><a href="http://manman.graz.funkfeuer.at/location/show/' + this.locid + '" target="_blank">Link-Database</td></tr>'; + html += '<tr><td>Smokeping:</td><td> </td><td><a href="http://stats.graz.funkfeuer.at/smokeping/?target=Funkfeuer.' + locations[this.locid].name + '" target="_blank">Link-Smokeping</td></tr>'; if(locations[this.locid].gallery_link) { - html += '<tr><td>Galerie:</td><td> </td><td><a href="' + locations[this.locid].gallery_link + '">Link</td></tr>'; + html += '<tr><td>Galerie:</td><td> </td><td><a href="' + locations[this.locid].gallery_link + '" target="_blank">Link-Galerie/Knoten</td></tr>'; } else { - html += '<tr><td>Galerie:</td><td> </td><td><a href="http://gallery.funkfeuer.at/v/Graz/Knoten/">Link</td></tr>'; - } + html += '<tr><td>Galerie:</td><td> </td><td><a href="http://gallery.funkfeuer.at/v/Graz/Knoten/" target="_blank">Link-Galerie</td></tr>'; + } + if (locations[this.locid].dnsnames){ + var dnsname = locations[this.locid].dnsnames.split(";"); + for (var i = 0;i < dnsname.length; ++i){ + if (dnsname[i]!==""){ + if(dnsname[i].indexOf(" (")>=0) { + link=dnsname[i].substring(0,dnsname[i].indexOf(" (")); + } else { + link=dnsname[i]; + } + html += '<tr><td> Router:</td><td> </td><td><a href="http://' + link+ '.ext.graz.funkfeuer.at/" target="_blank">'+dnsname[i]+'</td></tr>'; + } + } + } html += '</table>'; html += '</div>'; this.openInfoWindowHtml(html); } +function onLineClick(line,latlng) { +// var html ='<div id="linkbox" class="box">'; + var html ='<div class="locinfo">'; + html += '<b>'+line.name+'</b>'; + html += '<table class="linkinfo">'; + if (line.dnsfrom){ + var dnsfrom = line.dnsfrom.split(";"); + for (var i = 0;i < dnsfrom.length; ++i){ + if(dnsfrom[i].indexOf(" (")>=0) { + link=dnsfrom[i].substring(0,dnsfrom[i].indexOf(" (")); + } else { + link=dnsfrom[i]; + } + html += '<tr><td> Router:</td><td> </td><td><a href="http://' + link+ '.ext.graz.funkfeuer.at/" target="_blank">'+dnsfrom[i]+'</td></tr>'; + } + } + + if(line.dnsto){ + var dnsto = line.dnsto.split(";"); + for (var i = 0;i < dnsto.length; ++i){ + if(dnsto[i].indexOf(" (")>=0) { + link=dnsto[i].substring(0,dnsto[i].indexOf(" (")); + } else { + link=dnsto[i]; + } + html += '<tr><td> Router:</td><td> </td><td><a href="http://' + link+ '.ext.graz.funkfeuer.at/" target="_blank">'+dnsto[i]+'</td></tr>'; + } + } + html += '</table>'; + html += '</div>'; + map.openInfoWindowHtml(latlng,html); +} + function convertCoords(x) { var deg = Math.floor(x); var min = (x - deg) * 60; @@ -194,13 +266,33 @@ function convertCoords(x) { function drawLinks(xmlData) { var element = xmlData.getElementsByTagName("link"); for (var i = 0; i< element.length; i++) { + var state; + var color; + var textcolor; + var width; + state="Unbekannt" var id = element[i].getAttribute("from") + "-" + element[i].getAttribute("to"); links[id] = new Link(element[i]); var line = new GPolyline([links[id].frompoint, links[id].topoint], makeColor(Math.floor(links[id].value)), makeWeight(Math.floor(links[id].value))); + line.name = id; + line.textcolor = textcolor; + line.state = state; line.overlaytype = "link"; line.linkid = id; + line.dnsfrom = element[i].getAttribute("dnsfrom"); + line.dnsto = element[i].getAttribute("dnsto"); + line.Routerfrom = element[i].getAttribute("from"); + line.Routerto = element[i].getAttribute("to"); + GEvent.addListener(line, "mouseout", function() { lineinfo.style.visibility = "hidden"; }); + GEvent.addListener(line, "mouseover", function(point) { showLinkInfo(this, point)}); + GEvent.addListener(line, "click", function(point){onLineClick(this,point)}); +// GEvent.addListener(line, "click", function(latlng){map.openInfoWindowHtml(latlng, message)}); + map.addOverlay(line); + } + if(document.visibleform.elements["defaultroute"].checked) { + toggleVisible("defaultroute"); } if(document.visibleform.elements["bad"].checked) { toggleVisible("bad"); @@ -214,6 +306,80 @@ function drawLinks(xmlData) { if(document.visibleform.elements["tunnel"].checked) { toggleVisible("tunnel"); } + if(document.visibleform.elements["2.4channel"].checked) { + toggleVisible("2.4channel"); + } + if(document.visibleform.elements["channel1"].checked) { + toggleVisible("channel1"); + } + if(document.visibleform.elements["channel2"].checked) { + toggleVisible("channel2"); + } + if(document.visibleform.elements["channel3"].checked) { + toggleVisible("channel3"); + } + if(document.visibleform.elements["channel4"].checked) { + toggleVisible("channel4"); + } + if(document.visibleform.elements["channel5"].checked) { + toggleVisible("channel5"); + } + if(document.visibleform.elements["channel6"].checked) { + toggleVisible("channel6"); + } + if(document.visibleform.elements["channel7"].checked) { + toggleVisible("channel7"); + } + if(document.visibleform.elements["channel8"].checked) { + toggleVisible("channel8"); + } + if(document.visibleform.elements["channel9"].checked) { + toggleVisible("channel9"); + } + if(document.visibleform.elements["channel10"].checked) { + toggleVisible("channel10"); + } + if(document.visibleform.elements["channel11"].checked) { + toggleVisible("channel11"); + } + if(document.visibleform.elements["channel12"].checked) { + toggleVisible("channel12"); + } + if(document.visibleform.elements["channel13"].checked) { + toggleVisible("channel13"); + } + if(document.visibleform.elements["5channel"].checked) { + toggleVisible("5channel"); + } + if(document.visibleform.elements["undef"].checked) { + toggleVisible("undef"); + } +} +function showLinkInfo(link, point) { + var html = '<div id="linkbox" class="box" style="border-color: ' + link.color + '">'; + if((links[link.name].frequence !== "undef") && (links[link.name].frequence !== "")){ + html += '<strong>Frequenz:</strong> ' + links[link.name].frequence + '<br />'; + } else { + html += '<strong>Frequenz:</strong> undef <br />'; + } + if(links[link.name].channel !== "undef") { + html += '<strong>Kanal:</strong> ' + links[link.name].channel + '<br />'; + } else { + html += '<strong>Kanal:</strong> undef <br />'; + } + if (links[link.name].value !==-1){ + html += '<strong>Mittlerer ETX:</strong> ' + links[link.name].value + '<br />'; + } else { + html += '<strong>Mittlerer ETX:</strong> undef <br />'; + } + html += '<strong>Name:</strong> ' + link.name + '<br />'; + html += '<strong>Länge:</strong> ' + link.getLength().toFixed(0) + ' m<br />'; + html += '</div>'; + lineinfo.innerHTML = html; + var pos = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(180, 0)); + + pos.apply(lineinfo); + lineinfo.style.visibility = "visible"; } function Link(element) { @@ -231,7 +397,9 @@ function Link(element) { link.topoint = new GLatLng(lat, lng); link.value = parseFloat(element.getAttribute("value")); - + link.channel = element.getAttribute("channel"); + link.defaultroute = element.getAttribute("defaultroute"); + link.frequence = element.getAttribute("frequence"); return link; } @@ -279,13 +447,64 @@ function makeIcon(type) { function toggleVisible(element) { var elements = Object(); + if (element=='bad' || element=='middle' || element=='good'){ + document.visibleform.elements["2.4channel"].checked=false; + document.visibleform.elements["channel1"].checked=false; + document.visibleform.elements["channel2"].checked=false; + document.visibleform.elements["channel3"].checked=false; + document.visibleform.elements["channel4"].checked=false; + document.visibleform.elements["channel5"].checked=false; + document.visibleform.elements["channel6"].checked=false; + document.visibleform.elements["channel7"].checked=false; + document.visibleform.elements["channel8"].checked=false; + document.visibleform.elements["channel9"].checked=false; + document.visibleform.elements["channel10"].checked=false; + document.visibleform.elements["channel11"].checked=false; + document.visibleform.elements["channel12"].checked=false; + document.visibleform.elements["channel13"].checked=false; + document.visibleform.elements["5channel"].checked=false; + document.visibleform.elements["undef"].checked=false; + } + if (element=='2.4channel'){ + document.visibleform.elements["channel1"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel2"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel3"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel4"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel5"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel6"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel7"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel8"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel9"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel10"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel11"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel12"].checked=document.visibleform.elements["2.4channel"].checked; + document.visibleform.elements["channel13"].checked=document.visibleform.elements["2.4channel"].checked; + } switch(element) { + case 'defaultroute': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].defaultroute == '0');"); break; case 'offline': elements.overlays = overlays["locations"]; elements.select = new Function("id", "return (locations[overlays['locations'][id].locid].state == 'offline');"); break; case 'online': elements.overlays = overlays["locations"]; elements.select = new Function("id", "return (locations[overlays['locations'][id].locid].state != 'offline');"); break; case 'bad': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 6);"); break; case 'middle': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 3 && links[overlays['links'][id].linkid].value < 6);"); break; case 'good': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 0 && links[overlays['links'][id].linkid].value < 3);"); break; case 'tunnel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value == -1);"); break; + case 'channel1': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '1');"); break; + case 'channel2': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '2');"); break; + case 'channel3': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '3');"); break; + case 'channel4': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '4');"); break; + case 'channel5': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '5');"); break; + case 'channel6': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '6');"); break; + case 'channel7': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '7');"); break; + case 'channel8': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '8');"); break; + case 'channel9': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '9');"); break; + case 'channel10': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '10');"); break; + case 'channel11': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '11');"); break; + case 'channel12': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '12');"); break; + case 'channel13': document.visibleform.elements["2.4channel"].checked=false; elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].channel == '13');"); break; + case 'undef': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].frequence == 'undef');"); break; + case '2.4channel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].frequence == '2.4');"); break; + case '5channel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].frequence !=='2.4' && links[overlays['links'][id].linkid].frequence !=='undef');"); break; + } if(document.visibleform.elements[element].checked) { @@ -336,7 +555,8 @@ function addNewNodeText(point) { return html; } -function setNewMarker(point) { +function setNewMarker(point) { +/* var marker = new GMarker(point,{icon: makeIcon('newnode'), draggable: true}); GEvent.addListener(marker, "dragstart", function() { @@ -362,6 +582,14 @@ function setNewMarker(point) { marker.overlaytype = "newmarker"; map.addOverlay(marker); marker.openInfoWindowHtml(addNewNodeText(point)); +*/ + var marker = new GMarker(point,makeIcon('newnode')); + GEvent.addListener(marker,"infowindowclose",function () { + map.removeOverlay(marker); + }); + + map.addOverlay(marker); + marker.openInfoWindowHtml(addNewNodeText(point)); } function fflogin(username, password) { @@ -439,7 +667,7 @@ function showFFLogout(username) { function showAddress(address) { if (geocoder) { - address += ", Graz, Austria"; +// address += ", Graz, Austria"; geocoder.getLatLng(address, function(point) { if (!point) { @@ -511,7 +739,7 @@ RulerControl.prototype.initialize = function(map) { dist = (parseInt(dist)/1000).toFixed(1) + " km"; } distText.data = "Entfernung: " + dist; - var poly = new GPolyline(line,'#FFFF00', 8, 1) + var poly = new GPolyline(line,'#FFFF00', 3, 1) poly.overlaytype = "ruler"; poly.overlaysubtype = "line"; map.addOverlay(poly); @@ -576,5 +804,5 @@ RulerControl.prototype.initialize = function(map) { } RulerControl.prototype.getDefaultPosition = function() { - return new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(7, 7)); + return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(7, 7)); } |