From 060170fdb2ec56dde0276c867c6398c745ef238f Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 29 Dec 2013 22:59:44 +0000 Subject: clicking on links works now --- map.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/map.js b/map.js index 9644bf9..821df9b 100644 --- a/map.js +++ b/map.js @@ -182,18 +182,12 @@ 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 google.maps.Polyline({path: [links[id].frompoint, links[id].topoint], strokeColor: makeColor(Math.floor(links[id].value)), strokeWeight: makeWeight(Math.floor(links[id].value))}); line.name = id; - line.textcolor = textcolor; - line.state = state; + line.state = "Unbekannt"; line.overlaytype = "link"; line.linkid = id; line.dnsfrom = element[i].getAttribute("dnsfrom"); @@ -202,8 +196,7 @@ 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){onLinkClick(this,point)}); -// google.maps.event.addListener(line, "click", function(latlng){map.openInfoWindowHtml(latlng, message)}); + google.maps.event.addListener(line, "click", function(event) { onLinkClick(this, event.latLng) }); line.setMap(map); overlays["links"].push(line); @@ -321,7 +314,7 @@ function Link(element) { return link; } -function onLinkClick(line,latlng) { +function onLinkClick(line, latlng) { var html ='
'; html += ''+line.name+''; html += ''; @@ -330,7 +323,7 @@ function onLinkClick(line,latlng) { for (var i = 0;i < dnsfrom.length; ++i){ if(dnsfrom[i].indexOf(" (")>=0) { link=dnsfrom[i].substring(0,dnsfrom[i].indexOf(" (")); - } else { + } else { link=dnsfrom[i]; } html += ''; @@ -342,7 +335,7 @@ function onLinkClick(line,latlng) { for (var i = 0;i < dnsto.length; ++i){ if(dnsto[i].indexOf(" (")>=0) { link=dnsto[i].substring(0,dnsto[i].indexOf(" (")); - } else { + } else { link=dnsto[i]; } html += ''; @@ -350,7 +343,9 @@ function onLinkClick(line,latlng) { } html += '
Router: '+dnsfrom[i]+'
Router: '+dnsto[i]+'
'; html += '
'; - map.openInfoWindowHtml(latlng,html); + + var infowindow = new google.maps.InfoWindow({ content: html, position: latlng }); + infowindow.open(map); } function makeColor(value) { -- cgit v1.2.1