From: Anton Khorev Date: Fri, 16 Aug 2024 07:45:54 +0000 (+0300) Subject: Change zoom precision function X-Git-Tag: live~310^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/1951ed2eb8af93d71e4d10ce0ede81d3ee2090bd?hp=9b2db63a957a325d16e3989f08c483bd88f1993e Change zoom precision function This changes the number of fractional digits to log10(pixels / degrees) with pixels = 2**(8 + zoom) and degrees = 180. --- diff --git a/app/assets/javascripts/osm.js.erb b/app/assets/javascripts/osm.js.erb index e429f4479..e08528f84 100644 --- a/app/assets/javascripts/osm.js.erb +++ b/app/assets/javascripts/osm.js.erb @@ -204,7 +204,9 @@ OSM = { }, zoomPrecision: function(zoom) { - return Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)); + var pixels = Math.pow(2, 8 + zoom); + var degrees = 180; + return Math.ceil(Math.log10(pixels / degrees)); }, locationCookie: function(map) {