From e08c7b0ed46f4f88ec570926b6400704a5863a06 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 29 Dec 2013 20:14:35 +0000 Subject: overlay arrays redone --- map.css | 5 ++- map3.js | 114 +++++++++++++++++++++++++++++----------------------------------- 2 files changed, 54 insertions(+), 65 deletions(-) diff --git a/map.css b/map.css index fcc97f0..90ec25c 100644 --- a/map.css +++ b/map.css @@ -27,7 +27,6 @@ div.box { } #northeastcontainer { - position: absolute; right: 10px; top: 5ex; @@ -113,12 +112,12 @@ div.btn { *.locinfo,table { font-size: 8pt; - color: black; + color: black; } *.linkinfo,table { font-size: 8pt; - color: black; + color: black; } table.legend { margin-top: 3px; diff --git a/map3.js b/map3.js index 33b1d95..e5f81db 100644 --- a/map3.js +++ b/map3.js @@ -47,7 +47,6 @@ function initialize(lat, lng, res) { //##// map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(10,20))); //##// map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(50,10))); - google.maps.event.addListener(map, "addoverlay", onAddOverlay); google.maps.event.addListener(map, "click", onMapClick); lineinfo = document.createElement("div"); @@ -68,21 +67,17 @@ function initialize(lat, lng, res) { $.get( "data.php",onData); } -function onAddOverlay(overlay) { - debug("onAddOverlay called!"); - - switch(overlay.overlaytype) { - case "location": overlays["locations"].push(overlay); break; - case "link": overlays["links"].push(overlay); break; - case "ruler": { - if(overlays["ruler"][overlay.overlaysubtype]) { - map.removeOverlay(overlays["ruler"][overlay.overlaysubtype]); - } - overlays["ruler"][overlay.overlaysubtype] = overlay; - break; - } - } -} +// function onAddOverlay(overlay) { +// switch(overlay.overlaytype) { +// case "ruler": { +// if(overlays["ruler"][overlay.overlaysubtype]) { +// map.removeOverlay(overlays["ruler"][overlay.overlaysubtype]); +// } +// overlays["ruler"][overlay.overlaysubtype] = overlay; +// break; +// } +// } +// } function onMapClick(mouse_event) { @@ -96,14 +91,9 @@ function onMapClick(mouse_event) //##// return alert("Fehler: Konnte die Daten nicht laden!\n(Server Antwort-Code: " + responseCode + ")"); //##// } //##// reloadcon.loaded(); -function onData(data) { -//##// xmlData = GXml.parse(data); -//##//alert("Data Loaded: " +data.slice( 0, 100 )); - //##//xmlData = $.parseXML(data.responseText); - xmlData = data; - +function onData(xmlData) { for(var loc in overlays["locations"]) { - map.removeOverlay(overlays["locations"][loc]); + overlays["locations"][loc].setMap(null); } overlays["locations"] = []; locations = []; @@ -112,7 +102,7 @@ function onData(data) { } for(var link in overlays["links"]) { - map.removeOverlay(overlays["links"][link]); + overlays["links"][link].setMap(null); } overlays["links"] = []; links = []; @@ -139,8 +129,8 @@ function drawLocations(xmlData) { marker.overlaytype = "location"; marker.locid = id; google.maps.event.addListener(marker, "click", onLocationClick); -//##// map.addOverlay(marker); marker.setMap(map); + overlays["locations"].push(marker); } if(document.visibleform.elements["offline"].checked) { toggleVisible("offline"); @@ -167,7 +157,7 @@ function Location(element) { function onLocationClick(latlng) { var html = '
'; - html += '' + locations[this.locid].name + ''; + html += '' + locations[this.locid].name + ''; html += ''; html += ''; html += ''; @@ -197,39 +187,6 @@ function onLocationClick(latlng) { infowindow.open(map,this); } -function onLineClick(line,latlng) { -// var html ='
Breitengrad: ' + convertCoords(locations[this.locid].point.lat()) + '
' + locations[this.locid].point.lat().toFixed(6) + '
Längengrad: ' + convertCoords(locations[this.locid].point.lng()) + '
' + locations[this.locid].point.lng().toFixed(6) + '
'; - 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 += ''; - } - } - - 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 += ''; - } - } - html += '
Router: '+dnsfrom[i]+'
Router: '+dnsto[i]+'
'; - html += '
'; - map.openInfoWindowHtml(latlng,html); -} - function convertCoords(x) { var deg = Math.floor(x); var min = (x - deg) * 60; @@ -260,10 +217,11 @@ function drawLinks(xmlData) { line.Routerto = element[i].getAttribute("to"); google.maps.event.addListener(line, "mouseout", function() { lineinfo.style.visibility = "hidden"; }); // google.maps.event.addListener(line, "mouseover", function(point) { showLinkInfo(this, point)}); - google.maps.event.addListener(line, "click", function(point){onLineClick(this,point)}); + google.maps.event.addListener(line, "click", function(point){onLinkClick(this,point)}); // google.maps.event.addListener(line, "click", function(latlng){map.openInfoWindowHtml(latlng, message)}); line.setMap(map); + overlays["links"].push(line); } // if(document.visibleform.elements["defaultroute"].checked) { // toggleVisible("defaultroute"); @@ -378,6 +336,38 @@ function Link(element) { return link; } +function onLinkClick(line,latlng) { + var html ='
'; + html += ''+line.name+''; + html += ''; + 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 += ''; + } + } + + 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 += ''; + } + } + html += '
Router: '+dnsfrom[i]+'
Router: '+dnsto[i]+'
'; + html += '
'; + map.openInfoWindowHtml(latlng,html); +} + function makeColor(value) { switch(value) { case -1: return '#0000FF'; @@ -519,7 +509,7 @@ function addNewNodeText(point) { link += 'z_x=' + Math.floor(pixel_x % 100) + '&z_y=' + Math.floor(pixel_y % 100); link += '&c=' + Math.floor(pixel_x / 100) + '&r=' + Math.floor(pixel_y / 100); - var html = 'Neuen Knoten eintragen
Nutzen sie den Zoombereich aus!


'; + var html = 'Neuen Knoten eintragen
Nutzen sie den Zoombereich aus!


'; html += ''; html += ''; html += '
Breitengrad: ' + convertCoords(point.lat()) + '
' + point.lat().toFixed(6) + '
 
   ' + html += ''+username+'   ' html += '
'; document.getElementById("loginbox").innerHTML = html; -- cgit v1.2.1