From 14ada9839a41358c68ad979f94cc056d7e1415df Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Fri, 5 Dec 2008 22:58:42 +0000 Subject: added reload control --- map.css | 6 +++++- map.js | 73 ++++++++++++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/map.css b/map.css index 3299610..b5b5ae1 100644 --- a/map.css +++ b/map.css @@ -29,7 +29,7 @@ div.box { #legendbox { position: absolute; right: 10px; - top: 10px; + top: 4em; } #addressbox { @@ -68,3 +68,7 @@ div.btn { #rulerbtn { width: 10em; } + +#reloadbtn { + width: 10em; +} diff --git a/map.js b/map.js index b580b84..e264429 100644 --- a/map.js +++ b/map.js @@ -26,6 +26,7 @@ function initialize(lat, lng, res) { map.setZoom(res); } map.addControl(new RulerControl()); + map.addControl(new ReloadControl()); 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))); @@ -160,6 +161,32 @@ function showAddress(address) { } } +function ReloadControl() { +} + +ReloadControl.prototype = new GControl(); + +ReloadControl.prototype.initialize = function(map) { + var container = document.createElement("div"); + var btnDiv = document.createElement("div"); + btnDiv.className = "btn"; + btnDiv.id = "reloadbtn"; + container.appendChild(btnDiv); + btnText = document.createTextNode("Daten neu laden"); + btnDiv.appendChild(btnText); + GEvent.addDomListener(btnDiv, "click", function() { + GDownloadUrl("data.php", onData); + }); + + map.getContainer().appendChild(container); + return container; +} + +ReloadControl.prototype.getDefaultPosition = function() { + return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7)); +} + + function RulerControl() { } @@ -204,31 +231,31 @@ RulerControl.prototype.initialize = function(map) { btnText = document.createTextNode("Entfernung messen"); btnDiv.appendChild(btnText); GEvent.addDomListener(btnDiv, "click", function() { - for(var o in overlays["ruler"]) { - if(overlays["ruler"][o]) { - clr(); - return; + 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}); - marker1.overlaytype = "ruler"; - marker1.overlaysubtype = "marker1"; - map.addOverlay(marker1); - - marker2 = new GMarker(pnt, {icon: makeIcon('ruler'), draggable: true}); - marker2.overlaytype = "ruler"; - marker2.overlaysubtype = "marker2"; - map.addOverlay(marker2); - - GEvent.addListener(marker1, "drag", function() { measure(); }); - GEvent.addListener(marker2, "drag", function() { measure(); }); - }); + 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}); + marker1.overlaytype = "ruler"; + marker1.overlaysubtype = "marker1"; + map.addOverlay(marker1); + + marker2 = new GMarker(pnt, {icon: makeIcon('ruler'), draggable: true}); + marker2.overlaytype = "ruler"; + marker2.overlaysubtype = "marker2"; + map.addOverlay(marker2); + + GEvent.addListener(marker1, "drag", function() { measure(); }); + GEvent.addListener(marker2, "drag", function() { measure(); }); + }); distBoxOuter = document.createElement("div"); distBoxOuter.id = "distboxouter"; distBox = document.createElement("div"); -- cgit v1.2.1