From ce3487743a231579722fded89ede17c514ec59fe Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sat, 6 Dec 2008 21:53:22 +0000 Subject: offline locations can now be hidden --- map.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) (limited to 'map.js') diff --git a/map.js b/map.js index c43552e..553ba9e 100644 --- a/map.js +++ b/map.js @@ -118,6 +118,9 @@ function drawLocations(xmlData) { GEvent.addListener(marker, "click", onLocationClick); map.addOverlay(marker); } + if(document.visibleform.elements["offline"].checked) { + toggleVisible("offline"); + } } function Location(element) { @@ -153,10 +156,10 @@ function onLocationClick(latlng) { } 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) + "\""; + 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 addNewNodeText(point) { @@ -180,6 +183,28 @@ function makeIcon(type) { return icon } +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; + } + + 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].hide(); +} + +function showElements(elements) { + for(var o in elements.overlays) + if(elements.select(o)) elements.overlays[o].show(); +} function setNewMarker(point) { var marker = new GMarker(point,{icon: makeIcon('newnode'), draggable: true}); -- cgit v1.2.1