var map = "";
var gpsinfo = new Object();
var baseIcon;
var markerList = new Array();
function updateSelectBox() {
var status = document.getElementsByName("status");
var text = "";
var count = 0;
text += "";
text += ""
text += "";
// Button to select the two testboxes
text += ""
if( typeof(source) != "undefined" && typeof(target) != "undefined" )
text += "
";
// Show a zoom button to zoom into the relation, still needs to check better if the relation is actually displayed
//if( typeof(source) != "undefined" && isShown(source[0]) && typeof(target) != "undefined" && isShown(target[0]) )
// text += "Zoom";
if( count != 0 )
writit(text, "selectDiv");
else
writit("
No testboxes available in this filter mode.
", "selectDiv"); } // Creates a marker at the given point with the given number label function createMarker(point, status ,tb, descr, size) { var icon = new GIcon(baseIcon); if( status == "ON" ) { icon.image = "icons/g_"+size+".png"; icon.iconAnchor = new GPoint(size/2, size/2); } if( status == "OFF" ) { icon.image = "icons/r_"+size+".png"; icon.iconAnchor = new GPoint(size/2, size/2); } if( status == "SETUP" ) { icon.image = "icons/y_"+size+".png"; icon.iconAnchor = new GPoint(size/2, size/2); } if( status == "HISTORIC" ) { icon.image = "icons/w_"+size+".png"; icon.iconAnchor = new GPoint(size/2, size/2); } var marker = new GMarker(point,icon); GEvent.addListener(marker, "click", function() { doTestboxInfoWindow(marker, tb, status, descr, point); }); return marker; } function TBCenter(tb) { for (var tbstatus in gpsinfo) { if (gpsinfo[tbstatus][tb]) { map.setCenter(new GLatLng(gpsinfo[tbstatus][tb]["lat"], gpsinfo[tbstatus][tb]["long"]), 13); } } } function doTestboxInfoWindow(marker, tb, status, descr, point) { // Fetch Information we need if( status == "ON" ) { var statusName = "This testbox is currently Online."; } else if( status == "OFF" ) { var statusName = "This testbox is currently Offline."; } else if( status == "HISTORIC" ) { var statusName = "This testbox only offers historic data."; } else if( status == "SETUP" ) { var statusName = "This testbox is currently being setup and should be available soon."; } GDownloadUrl("../"+tb+"/weeksummary.xml", function(data, responseCode) { var xml = GXml.parse(data); var targetText = ""; var targets = xml.documentElement.getElementsByTagName("target"); for (var i = 0; i < targets.length; i++) { var tbName = targets[i].getAttribute("name"); // Check if testbox is on screen (needs to be redone for subset selection) if (gpsinfo["ON"][tbName] && isShown(tbName) ) { // And add it to our string targetText += ""+tbName+""; if( i < targets.length-1 ) { targetText += ", "; } } } // Show target selection only for ON testboxes. if (gpsinfo["ON"][tb]) { var infoTabs = [ new GInfoWindowTab("Overview", ""+ statusName+" "+descr+"
[Select as first testbox] [Select as second testbox]
"), new GInfoWindowTab("Targets", "The following testboxes are configured as targets of "+tb+":
"+targetText+"
") ]; } else { var infoTabs = [ new GInfoWindowTab("Overview", "
"+ statusName+" "+descr+"
") ]; } marker.openInfoWindowTabsHtml(infoTabs); }); } function selectTestbox(tb, sort) { // sort variable lets you (optional) select weather the given testbox shall be source or target // We have to grab Lat/Lng on our own for (var tbstatus in gpsinfo) { if (gpsinfo[tbstatus][tb]) { pointLat = gpsinfo[tbstatus][tb]["lat"]; pointLng = gpsinfo[tbstatus][tb]["long"]; } } // Make the old source the new target. if( typeof(sort) == "undefined" ) { target = source; if( typeof(target) == "undefined" || target[0] != tb ) { source = [tb, new GLatLng(pointLat, pointLng)]; if( typeof(target) != "undefined" ) { drawRelation(); } } } else { if( sort == 0 ) { // tb shall be the new source if( typeof(target) == "undefined" || target[0] != tb ) { source = [tb, new GLatLng(pointLat, pointLng)]; } } else { // tb shall be the new target if( typeof(source) == "undefined" || source[0] != tb ) { target = [tb, new GLatLng(pointLat, pointLng)]; } } if( typeof(target) != "undefined" && typeof(source) != "undefined" ) { drawRelation(); GEvent.trigger(relationMarker, 'click'); } } updateSelectBox(); } var mMgr = null; function loadTTM() { if (GBrowserIsCompatible()) { var qs = new Querystring(); map = new GMap2(document.getElementById("map")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); map.addControl(new GScaleControl()); map.addControl(new GOverviewMapControl()); map.setCenter(new GLatLng(30, 0), 2); map.setMapType(G_HYBRID_MAP); map.enableDoubleClickZoom(); map.enableContinuousZoom(); //map.enableScrollWheelZoom(); baseIcon = new GIcon(); //baseIcon.shadow = "/locations/tb-shadow.png" //baseIcon.iconSize = new GSize(25, 25); baseIcon.shadowSize = new GSize(30, 30); baseIcon.iconAnchor = new GPoint(9, 25); baseIcon.infoWindowAnchor = new GPoint(20, 5); baseIcon.infoShadowAnchor = new GPoint(0,0); mMgr = new MarkerManager(map); GDownloadUrl("../GPSINFO.xml", function(data, responseCode) { var xml = GXml.parse(data); if (responseCode != 200) { alert("Couldn't load GPSINFO.xml: http status code " + responseCode); } else { var tbs = xml.documentElement.getElementsByTagName("tb"); for (var i = 0; i < tbs.length; i++) { var tbid = tbs[i].getAttribute("ttid"); var status = tbs[i].getAttribute("status"); var gpslat = parseFloat(tbs[i].getAttribute("latitude")); var gpslong = parseFloat(tbs[i].getAttribute("longitude")); var description = "It is operated by " + tbs[i].getAttribute("org") + " in " + tbs[i].getAttribute("city") + ", " + tbs[i].getAttribute("country")+"."; var shortDescr = tbid + ", " + tbs[i].getAttribute("city") + " (" + tbs[i].getAttribute("country") + ")"; if (gpslat || gpslong ) { var point = new GLatLng(gpslat,gpslong); if (!gpsinfo) { gpsinfo = new Object(); } if (!gpsinfo[status]){ gpsinfo[status] = new Object(); } if (!gpsinfo[status][tbid]) { gpsinfo[status][tbid] = new Object(); } gpsinfo[status][tbid]["lat"] = gpslat; gpsinfo[status][tbid]["long"] = gpslong; gpsinfo[status][tbid]["descr"] = description; gpsinfo[status][tbid]["shortDescr"] = shortDescr; // pleaseHideLater taken from http://groups.google.com/group/Google-Maps-API/browse_thread/thread/0735494b4ab42452/e803d9e8dff1ac70 var marker0 = createMarker(point, status, tbid, description, 24 ); marker0.pleaseHideLater = false var marker1 = createMarker(point, status, tbid, description, 32 ); marker1.pleaseHideLater = false; var marker2 = createMarker(point, status, tbid, description, 48 ); marker2.pleaseHideLater = false; var marker3 = createMarker(point, status, tbid, description, 64 ); marker3.pleaseHideLater = false; //map.addOverlay(marker); if( status != "ON" ) { // pleaseHideLater taken from http://groups.google.com/group/Google-Maps-API/browse_thread/thread/0735494b4ab42452/e803d9e8dff1ac70 marker0.pleaseHideLater = true; marker0.hide(); marker1.pleaseHideLater = true; marker1.hide(); marker2.pleaseHideLater = true; marker2.hide(); marker3.pleaseHideLater = true; marker3.hide(); } mMgr.addMarker(marker0, 0, 5); mMgr.addMarker(marker1, 6, 10); mMgr.addMarker(marker2, 11, 15); mMgr.addMarker(marker3, 16); gpsinfo[status][tbid]["marker0"] = marker0; gpsinfo[status][tbid]["marker1"] = marker1; gpsinfo[status][tbid]["marker2"] = marker2; gpsinfo[status][tbid]["marker3"] = marker3; } } mMgr.refresh(); gpsinfo["CUSTOM"] = new Object(); var select_box = ""; select_box += ''; select_box += 'Testbox in custom list (click to remove): None