X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/8dfecbfbb2b246440fd09a0a4c2190c26a20b37e..bc309badb8c3afea20c17ff9ef44861d4f7bcf13:/public/javascripts/site.js diff --git a/public/javascripts/site.js b/public/javascripts/site.js index 95ef1f536..6fb68e65a 100644 --- a/public/javascripts/site.js +++ b/public/javascripts/site.js @@ -1,13 +1,31 @@ function updatelinks(lon,lat,zoom,layers) { + var decimals = Math.pow(10, Math.floor(zoom/3)); var node; + lat = Math.round(lat * decimals) / decimals; + lon = Math.round(lon * decimals) / decimals; + + node = document.getElementById("permalinkanchor"); + if (node) { + var args = getArgs(node.href); + args["lat"] = lat; + args["lon"] = lon; + args["zoom"] = zoom; + if (layers) { + args["layers"] = layers; + } + node.href = setArgs(node.href, args); + } + node = document.getElementById("viewanchor"); if (node) { var args = getArgs(node.href); args["lat"] = lat; args["lon"] = lon; args["zoom"] = zoom; - args["layers"] = layers; + if (layers) { + args["layers"] = layers; + } node.href = setArgs(node.href, args); }