1 //Called as the user scrolls/zooms around.
2 //Maniplate hrefs of the view tab and various other links
3 function updatelinks(lon,lat,zoom,layers,extents) {
4 var decimals = Math.pow(10, Math.floor(zoom/3));
7 lat = Math.round(lat * decimals) / decimals;
8 lon = Math.round(lon * decimals) / decimals;
10 node = document.getElementById("permalinkanchor");
12 var args = getArgs(node.href);
17 args["layers"] = layers;
19 node.href = setArgs(node.href, args);
22 node = document.getElementById("viewanchor");
24 var args = getArgs(node.href);
29 args["layers"] = layers;
31 node.href = setArgs(node.href, args);
34 node = document.getElementById("exportanchor");
36 var args = getArgs(node.href);
41 args["layers"] = layers;
43 node.href = setArgs(node.href, args);
46 node = document.getElementById("editanchor");
49 var args = new Object();
53 node.href = setArgs("/edit", args);
54 node.style.fontStyle = 'normal';
56 node.href = 'javascript:alert("zoom in to edit map");';
57 node.style.fontStyle = 'italic';
61 node = document.getElementById("historyanchor");
64 var args = new Object();
65 //set bbox param from 'extents' object
66 minlon = extents.left;
67 minlat = extents.bottom;
68 maxlon = extents.right;
70 minlon = Math.round(minlon * decimals) / decimals;
71 minlat = Math.round(minlat * decimals) / decimals;
72 maxlon = Math.round(maxlon * decimals) / decimals;
73 maxlat = Math.round(maxlat * decimals) / decimals;
74 args.bbox = minlon + "," + minlat + "," + maxlon + "," + maxlat;
75 node.href = setArgs("history/", args);
76 node.style.fontStyle = 'normal';
78 node.href = 'javascript:alert("zoom in to see editing history");';
79 node.style.fontStyle = 'italic';
84 function getArgs(url) {
85 var args = new Object();
86 var querystart = url.indexOf("?");
88 if (querystart >= 0) {
89 var querystring = url.substring(querystart + 1);
90 var queryitems = querystring.split("&");
92 for (var i = 0; i < queryitems.length; i++) {
93 if (match = queryitems[i].match(/^(.*)=(.*)$/)) {
94 args[unescape(match[1])] = unescape(match[2]);
96 args[unescape(queryitems[i])] = null
104 function setArgs(url, args) {
105 var queryitems = new Array();
109 if (args[arg] == null) {
110 queryitems.push(escape(arg));
112 queryitems.push(escape(arg) + "=" + escape(args[arg]));
116 return url.replace(/\?.*$/, "") + "?" + queryitems.join("&");
119 function getStyle(el, property) {
122 if (el.currentStyle) {
123 style = el.currentStyle[property];
124 } else if( window.getComputedStyle ) {
125 style = document.defaultView.getComputedStyle(el,null).getPropertyValue(property);
127 style = el.style[property];