var map = null;
var linkinfo;
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 links = new Array();
debug = function (log_txt) {
if (typeof window.console != 'undefined') {
console.log(log_txt);
}
}
function initialize(lat, lng, res) {
debug("Initializing Funkfeuer Graz Map");
var OSM_Mapnik = 'OSM_Mapnik';
var copyrightNode = document.createElement('div');
copyrightNode.id = 'copyright-control';
copyrightNode.style.fontSize = '11px';
copyrightNode.style.fontFamily = 'Arial, sans-serif';
copyrightNode.style.margin = '0 2px 2px 0';
copyrightNode.style.whitespace = 'nowrap';
copyrightNode.innerHTML = 'Map data © OpenStreetMap / Google';
copyrightNode.index = 0;
google.maps.visualRefresh=true;
var mapOptions = {
center: new google.maps.LatLng(lat, lng), zoom: res,
streetViewControl: false, disableDoubleClickZoom: true,
mapTypeId: OSM_Mapnik,
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.HYBRID,
google.maps.MapTypeId.SATELLITE , google.maps.MapTypeId.TERRAIN,
OSM_Mapnik ],
style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
}
};
map = new google.maps.Map(document.getElementById("map"), mapOptions);
map.mapTypes.set("OSM_Mapnik", new google.maps.ImageMapType({
getTileUrl: function(coord, zoom) {
return "//tile.openstreetmap.org/" + zoom + "/" + coord.x + "/" + coord.y + ".png";
},
tileSize: new google.maps.Size(256, 256),
name: "OpenStreetMap",
maxZoom: 18
}));
map.controls[google.maps.ControlPosition.BOTTOM_RIGHT].push(copyrightNode);
//##// map.addControl(new RulerControl());
var reloadconDiv = document.createElement('div');
reloadcon = new ReloadControl(reloadconDiv, map);
map.controls[google.maps.ControlPosition.TOP_RIGHT].push(reloadconDiv);
google.maps.event.addListener(map, "click", onMapClick);
linkinfo = document.createElement("div");
document.getElementById("map").appendChild(linkinfo);
linkinfo.style.visibility = "hidden"
dnsinfo = document.createElement("div");
document.getElementById("map").appendChild(dnsinfo);
dnsinfo.style.visibility = "hidden"
// geocoder = new google.maps.Geocoder();
var countbox = document.getElementById("countbox");
countboxText = document.createTextNode("Aktiv: 0");
countbox.appendChild(countboxText);
reloadcon.reload();
}
function onMapClick(mouse_event)
{
map.setCenter(mouse_event.latLng);
setNewMarker(mouse_event.latLng);
}
function onDataErr() {
reloadcon.finished();
}
function onData(xmlData) {
reloadcon.loaded();
for(var loc in overlays["locations"]) {
overlays["locations"][loc].setMap(null);
}
overlays["locations"] = [];
locations = [];
if (xmlData) {
drawLocations(xmlData);
}
for(var link in overlays["links"]) {
overlays["links"][link].setMap(null);
}
overlays["links"] = [];
links = [];
if (xmlData) {
drawLinks(xmlData);
}
if (xmlData) {
var element = xmlData.getElementsByTagName("count");
var count = element[0].getAttribute("number");
countboxText.data = "Aktiv: " + count;
}
reloadcon.finished();
}
function drawLocations(xmlData) {
var element = xmlData.getElementsByTagName("node");
for (var i = 0; i< element.length; i++) {
var id = parseInt(element[i].getAttribute("id"));
locations[id] = new Location(element[i]);
var marker = new google.maps.Marker({position: locations[id].point, icon: makeIcon(locations[id].state)});
marker.locid = id;
google.maps.event.addListener(marker, "click", onLocationClick);
marker.setMap(map);
overlays["locations"].push(marker);
}
if(document.visibleform.elements["offline"].checked) {
toggleVisible("offline");
}
if(document.visibleform.elements["online"].checked) {
toggleVisible("online");
}
}
function Location(element) {
var location = new Object();
location.name = element.getAttribute("name");
var lat = parseFloat(element.getAttribute("lat"));
var lng = parseFloat(element.getAttribute("lng"));
location.point = new google.maps.LatLng(lat, lng);
location.pixel_x = parseInt(element.getAttribute("pixel_x"));
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;
}
function onLocationClick(latlng) {
var html = '
';
html += '
' + locations[this.locid].name + '';
html += '
';
html += 'Breitengrad: | | ' + convertCoords(locations[this.locid].point.lat()) + ' ' + locations[this.locid].point.lat().toFixed(6) + ' |
';
html += 'Längengrad: | | ' + convertCoords(locations[this.locid].point.lng()) + ' ' + locations[this.locid].point.lng().toFixed(6) + ' |
';
html += 'Datenbank: | | Link-Database |
';
html += 'Smokeping: | | Link-Smokeping |
';
if(locations[this.locid].gallery_link) {
html += 'Galerie: | | Link-Galerie/Knoten |
';
} else {
html += 'Galerie: | | Link-Galerie |
';
}
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 += ' Router: | | '+dnsname[i]+' |
';
}
}
}
html += '
';
html += '
';
var infowindow = new google.maps.InfoWindow({content: html});
infowindow.open(map,this);
}
function convertCoords(x) {
var deg = Math.floor(x);
var min = (x - deg) * 60;
var sec = (min - Math.floor(min)) * 60;
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 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.state = "Unbekannt";
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");
// google.maps.event.addListener(line, "mouseout", function() { linkinfo.style.visibility = "hidden"; });
// google.maps.event.addListener(line, "mouseover", function(point) { showLinkInfo(this, point)});
google.maps.event.addListener(line, "click", function(event) { onLinkClick(this, event.latLng) });
line.setMap(map);
overlays["links"].push(line);
}
if(document.visibleform.elements["defaultroute"].checked) {
toggleVisible("defaultroute");
}
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");
}
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 = '';
if((links[link.name].frequency !== "undef") && (links[link.name].frequency !== "")){
html += 'Frequenz: ' + links[link.name].frequency + '
';
} else {
html += 'Frequenz: undef
';
}
if(links[link.name].channel !== "undef") {
html += 'Kanal: ' + links[link.name].channel + '
';
} else {
html += 'Kanal: undef
';
}
if (links[link.name].value !==-1){
html += 'Mittlerer ETX: ' + links[link.name].value + '
';
} else {
html += 'Mittlerer ETX: undef
';
}
html += 'Name: ' + link.name + '
';
//##// html += 'Länge: ' + link.getLength().toFixed(0) + ' m
';
html += '
';
linkinfo.innerHTML = html;
//##// var pos = new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(180, 0));
//##// pos.apply(linkinfo);
linkinfo.style.visibility = "visible";
}
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 google.maps.LatLng(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 google.maps.LatLng(lat, lng);
link.value = parseFloat(element.getAttribute("value"));
link.channel = element.getAttribute("channel");
link.defaultroute = element.getAttribute("defaultroute");
link.frequency = element.getAttribute("frequency");
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 += ' Router: | | '+dnsfrom[i]+' |
';
}
}
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 += ' Router: | | '+dnsto[i]+' |
';
}
}
html += '
';
html += '
';
var infowindow = new google.maps.InfoWindow({ content: html, position: latlng });
infowindow.open(map);
}
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 '#666666'
}
}
function makeWeight(value) {
switch(value) {
case -1: return 2;
case 0: return 1;
case 1: return 3;
case 2: return 2;
case 3: return 1;
case 4: return 1;
case 5: return 1;
default: return 1;
}
}
function makeIcon(type) {
var url;
switch(type) {
case 'ruler': url = "./img/marker_blue.png"; break;
case 'newnode': url = "./img/marker_darkred.png"; break;
case 'online': url = "./img/marker_online.png"; break;
case 'tunnel': url = "./img/marker_tunnel.png"; break;
case 'offline': url = "./img/marker_offline.png"; break;
}
return {
'url': url,
size: new google.maps.Size(12, 20),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(6, 20)
};
}
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].frequency == 'undef');"); break;
case '2.4channel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].frequency == '2.4');"); break;
case '5channel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].frequency !=='2.4' && links[overlays['links'][id].linkid].frequency !=='undef');"); break;
}
if(document.visibleform.elements[element].checked) {
hideElements(elements);
} else {
showElements(elements);
}
}
function hideElements(elements) {
for(var o in elements.overlays)
if(elements.select(o)) elements.overlays[o].setVisible(false);
}
function showElements(elements) {
for(var o in elements.overlays)
if(elements.select(o)) elements.overlays[o].setVisible(true);
}
function centerAndZoom(lat, lng) {
map.setCenter(new google.maps.LatLng(lat, lng));
map.setZoom(20);
}
function addNewNodeText(point) {
var x_startpoint = 4080;
var lng_startpoint = 15.43844103813;
var dx_dlng = 50675.5176;
var y_startpoint = 4806;
var lat_startpoint = 47.07177327969;
var dy_dlat = 75505.521;
var pixel_x = parseInt(Math.floor(x_startpoint + (point.lng() - lng_startpoint) * dx_dlng));
var pixel_y = parseInt(Math.floor(y_startpoint - (point.lat() - lat_startpoint) * dy_dlat));
var link = 'https://manman.graz.funkfeuer.at/location/new?';
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!
';
html += '';
html += 'Breitengrad: | | ' + convertCoords(point.lat()) + ' ' + point.lat().toFixed(6) + ' | | ';
html += ' |
';
html += 'Längengrad: | | ' + convertCoords(point.lng()) + ' ' + point.lng().toFixed(6) + ' | | ';
html += ' |
';
html += '
';
return html;
}
function setNewMarker(point) {
var marker = new google.maps.Marker({position: point, icon: makeIcon('newnode')});
var infowindow = new google.maps.InfoWindow({ content: addNewNodeText(point) });
google.maps.event.addListener(infowindow,"closeclick",function () { marker.setMap(null); });
marker.setMap(map);
infowindow.open(map,marker);
if(overlays["newmarker"]) {
overlays["newmarker"].setMap(null);
}
overlays['newmarker'] = marker;
}
function fflogin(username, password) {
$.post("login.php", { username: username, password: password, login: "Einloggen#" } )
.done(function(data) { onFFLogin(data); });
}
function onFFLogin(xmlData) {
var error = xmlData.getElementsByTagName("error");
if(error.length > 0) {
alert(error[0].getAttribute("string"));
}
else {
var status = xmlData.getElementsByTagName("status");
if(status[0].getAttribute("code") == "logged_in") {
var username = xmlData.getElementsByTagName("username")[0].getAttribute("name");
showFFLogout(username);
reloadcon.reload();
}
}
}
function showFFLogin() {
var html = '';
document.getElementById("loginbox").innerHTML = html;
}
function fflogout() {
$.post("login.php", { logout: "Ausloggen#" } )
.done(function(data) { onFFLogout(data); });
}
function onFFLogout(xmlData) {
var error = xmlData.getElementsByTagName("error");
if(error.length > 0) {
alert(error[0].getAttribute("string"));
}
else {
showFFLogin();
reloadcon.reload();
}
}
function showFFLogout(username) {
var html = '';
document.getElementById("loginbox").innerHTML = html;
}
function showAddress(address) {
if (geocoder) {
// address += ", Graz, Austria";
geocoder.getLatLng(address,
function(point) {
if (!point) {
alert(address + " nicht gefunden");
} else {
map.setCenter(point);
setNewMarker(point);
}
});
}
}
function ReloadControl(controlDiv, map) {
controlDiv.style.padding = '5px';
var controlUI = document.createElement('div');
controlUI.className = 'btn';
controlUI.title = 'Click to reload data';
controlDiv.appendChild(controlUI);
var controlText = document.createElement('div');
controlText.innerHTML = 'Daten neu laden';
controlUI.appendChild(controlText);
var cntrl = new Object();
cntrl.reload = function() {
controlText.innerHTML = 'wird geladen...';
$.get("data.php", onData).fail(onDataErr);
}
cntrl.loaded = function() { controlText.innerHTML = 'wird verarbeitet...'; }
cntrl.finished = function() { controlText.innerHTML = 'Daten neu laden'; }
google.maps.event.addDomListener(controlUI, 'click', cntrl.reload);
return cntrl;
}
//##//function RulerControl() {
//##//}
//##//
//##//RulerControl.prototype = new GControl();
//##//
//##//RulerControl.prototype.initialize = function(map) {
//##// var btnText;
//##// var distBoxOuter;
//##// var distBox;
//##// var distText;
//##//
//##// function measure() {
//##// if(overlays["ruler"]["marker1"] && overlays["ruler"]["marker2"]) {
//##// var line = [overlays["ruler"]["marker1"].getPoint(), overlays["ruler"]["marker2"].getPoint()];
//##// var dist = overlays["ruler"]["marker1"].getPoint().distanceFrom(overlays["ruler"]["marker2"].getPoint());
//##// dist = dist.toFixed(0)+" m";
//##// if(parseInt(dist) > 10000) {
//##// dist = (parseInt(dist)/1000).toFixed(1) + " km";
//##// }
//##// distText.data = "Entfernung: " + dist;
//##// var poly = new GPolyline(line,'#FFFF00', 3, 1)
//##// poly.overlaysubtype = "line";
//##// map.addOverlay(poly);
//##// }
//##// }
//##//
//##// function clr(){
//##// for(var o in overlays["ruler"]) {
//##// map.removeOverlay(overlays["ruler"][o]);
//##// }
//##// overlays["ruler"] = [];
//##// distBox.style.visibility = "hidden";
//##// btnText.data = "Entfernung messen";
//##// }
//##//
//##// var container = document.createElement("div");
//##// var btnDiv = document.createElement("div");
//##// btnDiv.className = "btn";
//##// btnDiv.id = "rulerbtn";
//##// container.appendChild(btnDiv);
//##// btnText = document.createTextNode("Entfernung messen");
//##// btnDiv.appendChild(btnText);
//##// google.maps.event.addDomListener(btnDiv, "click", function() {
//##// for(var o in overlays["ruler"]) {
//##// if(overlays["ruler"][o]) {
//##// clr();
//##// return;
//##// }
//##// }
//##//
//##// btnText.data = "Messung beenden";
//##// distText.data = "Entfernung: 0 m";
//##// distBox.style.visibility = "visible";
//##//
//##// var pnt = map.getCenter();
//##// marker1 = new GMarker(pnt, {icon: makeIcon('ruler'), draggable: true});
//##// map.addOverlay(marker1);
//##//
//##// marker2 = new GMarker(pnt, {icon: makeIcon('ruler'), draggable: true});
//##// map.addOverlay(marker2);
//##//
//##// google.maps.event.addListener(marker1, "drag", function() { measure(); });
//##// google.maps.event.addListener(marker2, "drag", function() { measure(); });
//##// });
//##// distBoxOuter = document.createElement("div");
//##// distBoxOuter.id = "distboxouter";
//##// distBox = document.createElement("div");
//##// distBox.className = "box";
//##// distBox.id = "distbox";
//##// distBox.style.visibility = "hidden";
//##// distText = document.createTextNode("Entfernung: ? m");
//##// distBox.appendChild(distText);
//##// distBoxOuter.appendChild(distBox);
//##// document.getElementById("map").appendChild(distBoxOuter);
//##//
//##// map.getContainer().appendChild(container);
//##// return container;
//##//}
//##//
//##//RulerControl.prototype.getDefaultPosition = function() {
//##//return new GControlPosition(G_ANCHOR_BOTTOM_RIGHT, new GSize(7, 7));
//##//}