summaryrefslogtreecommitdiff
path: root/map.js
diff options
context:
space:
mode:
authorChristian Pointner <equinox@ffgraz.net>2008-12-07 00:26:18 +0000
committerChristian Pointner <equinox@ffgraz.net>2008-12-07 00:26:18 +0000
commit3d4bdf9088184500442c451b237fcc2e954a7b21 (patch)
tree4b96fc2326710261aca364365564876b0f5600db /map.js
parentf3902147657cf2773e73f76f7e5fe810d0db6c78 (diff)
drawing links now
Diffstat (limited to 'map.js')
-rw-r--r--map.js89
1 files changed, 88 insertions, 1 deletions
diff --git a/map.js b/map.js
index 2864643..6a4d1ab 100644
--- a/map.js
+++ b/map.js
@@ -1,13 +1,15 @@
var map = null;
var physicalMaxLevel;
var geocoder = null;
+var reloadcon = null;
var countboxText = null;
var overlays = new Array();
overlays["newmarker"] = null;
overlays["ruler"] = new Array();
overlays["locations"] = new Array();
+overlays["links"] = new Array();
var locations = new Array();
-var reloadcon = null;
+var links = new Array();
function initialize(lat, lng, res) {
if (!checkBrowser()) {
@@ -69,6 +71,7 @@ function checkBrowser() {
function onAddOverlay(overlay) {
switch(overlay.overlaytype) {
case "location": overlays["locations"].push(overlay); break;
+ case "link": overlays["links"].push(overlay); break;
case "newmarker": {
if(overlays["newmarker"]) {
map.removeOverlay(overlays["newmarker"]);
@@ -114,6 +117,13 @@ function onData(data, responseCode) {
locations = [];
drawLocations(xmlData);
+ for(var link in overlays["links"]) {
+ map.removeOverlay(overlays["links"][link]);
+ }
+ overlays["links"] = [];
+ links = [];
+ drawLinks(xmlData);
+
var element = xmlData.getElementsByTagName("count");
var count = element[0].getAttribute("number");
countboxText.data = "Aktiv: " + count;
@@ -136,6 +146,9 @@ function drawLocations(xmlData) {
if(document.visibleform.elements["offline"].checked) {
toggleVisible("offline");
}
+ if(document.visibleform.elements["online"].checked) {
+ toggleVisible("online");
+ }
}
function Location(element) {
@@ -177,6 +190,75 @@ function convertCoords(x) {
return deg + "° " + Math.floor(min) + "' " + sec.toFixed(0) + "\"";
}
+function drawLinks(xmlData) {
+ var element = xmlData.getElementsByTagName("link");
+ for (var i = 0; i< element.length; i++) {
+ 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.overlaytype = "link";
+ line.linkid = id;
+ map.addOverlay(line);
+ }
+ if(document.visibleform.elements["bad"].checked) {
+ toggleVisible("bad");
+ }
+ if(document.visibleform.elements["middle"].checked) {
+ toggleVisible("middle");
+ }
+ if(document.visibleform.elements["good"].checked) {
+ toggleVisible("good");
+ }
+ if(document.visibleform.elements["tunnel"].checked) {
+ toggleVisible("tunnel");
+ }
+}
+
+function Link(element) {
+ var link = new Object();
+ link.from = element.getAttribute("from");
+ link.fromid = parseInt(element.getAttribute("fromid"));
+ var lat = parseFloat(element.getAttribute("latfrom"));
+ var lng = parseFloat(element.getAttribute("lngfrom"));
+ link.frompoint = new GLatLng(lat, lng);
+
+ link.to = element.getAttribute("to");
+ link.toid = parseInt(element.getAttribute("toid"));
+ lat = parseFloat(element.getAttribute("latto"));
+ lng = parseFloat(element.getAttribute("lngto"));
+ link.topoint = new GLatLng(lat, lng);
+
+ link.value = parseFloat(element.getAttribute("value"));
+
+ return link;
+}
+
+function makeColor(value) {
+ switch(value) {
+ case -1: return '#0000FF';
+ case 0: return '#FF0000';
+ case 1: return '#33bb33';
+ case 2: return '#66bb33';
+ case 3: return '#ff9900';
+ case 4: return '#ffcc00';
+ case 5: return '#cccc33';
+ default: return '#000000'
+ }
+}
+
+function makeWeight(value) {
+ switch(value) {
+ case -1: return 1;
+ case 0: return 3;
+ case 1: return 3;
+ case 3: return 1;
+ case 4: return 1;
+ case 5: return 1;
+ default: return 1;
+ }
+}
+
function addNewNodeText(point) {
var html = "adding location at: <br />\n" + point;
return html;
@@ -202,6 +284,11 @@ function toggleVisible(element) {
var elements = Object();
switch(element) {
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;
}
if(document.visibleform.elements[element].checked) {