Last active
February 15, 2017 13:59
-
-
Save panzi/6694200 to your computer and use it in GitHub Desktop.
The new Google Maps seems to use a diameter instead of a zoom value. You can use this function to get the old zoom value from the diameter. I tested it with the given list of values.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function diameterToZoom (diameter) { | |
var zoom = Math.floor(19 - Math.log(diameter / 1000) / Math.LN2); | |
return zoom < 0 ? 0 : zoom > 20 ? 20 : zoom; | |
} | |
// tested with these values: | |
// diameter = zoom | |
// 758 = 19 | |
// 1515 = 18 | |
// 3031 = 17 | |
// 6061 = 16 | |
// 12122 = 15 | |
// 24242 = 14 | |
// 48480 = 13 | |
// 96955 = 12 | |
// 193999 = 11 | |
// 388357 = 10 | |
// 777642 = 9 | |
// 1530533 = 8 | |
// 3067439 = 7 | |
// 7107071 = 6 | |
// 12407563 = 5 | |
// 27301053 = 4 | |
// 51957442 = 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment