Skip to content

Commit

Permalink
Change zoom precision function
Browse files Browse the repository at this point in the history
This changes the number of fractional digits to log10(pixels / degrees) with pixels = 2**(8 + zoom) and degrees = 180.
  • Loading branch information
AntonKhorev committed Aug 17, 2024
1 parent 9b2db63 commit 1951ed2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/assets/javascripts/osm.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1951ed2

Please sign in to comment.