X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/d9054cfe29efeb615237a143ca620c53af37288f..93c392cf5f7155a243cc6ebcab622be44dadc9ad:/app/assets/javascripts/application.js diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index e02949f58..df8dcda15 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -2,6 +2,7 @@ //= require jquery_ujs //= require jquery.autogrowtextarea //= require jquery.timers +//= require augment //= require openlayers //= require i18n/translations //= require globals @@ -9,23 +10,31 @@ //= require export //= require map //= require menu +//= require sidebar + +function zoomPrecision(zoom) { + var decimals = Math.pow(10, Math.floor(zoom/3)); + return function(x) { + return Math.round(x * decimals) / decimals; + }; +} /* * Called as the user scrolls/zooms around to aniplate hrefs of the * view tab and various other links */ function updatelinks(lon,lat,zoom,layers,minlon,minlat,maxlon,maxlat,objtype,objid) { - var decimals = Math.pow(10, Math.floor(zoom/3)); + var toPrecision = zoomPrecision(zoom); var node; - lat = Math.round(lat * decimals) / decimals; - lon = Math.round(lon * decimals) / decimals; + lat = toPrecision(lat); + lon = toPrecision(lon); if (minlon) { - minlon = Math.round(minlon * decimals) / decimals; - minlat = Math.round(minlat * decimals) / decimals; - maxlon = Math.round(maxlon * decimals) / decimals; - maxlat = Math.round(maxlat * decimals) / decimals; + minlon = toPrecision(minlon); + minlat = toPrecision(minlat); + maxlon = toPrecision(maxlon); + maxlat = toPrecision(maxlat); } $(".geolink").each(function (index, link) {