Created
January 20, 2015 12:29
-
-
Save gagan-bansal/db6fb206f61b38f2f1c3 to your computer and use it in GitHub Desktop.
Calculate google maps (or web mercator projection) zoom level resolutions.
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
var extent = { | |
left: -20037508.342789244, | |
right: 20037508.342789244, | |
bottom: -20037508.342789244, | |
top: 20037508.342789244 | |
}; | |
var size = 256; // map tile size | |
var resolutions = []; | |
for (var i=0; i< 24; i++) { | |
resolutions.push( (extent.right - extent.left) / (256 * Math.pow(2,i)) ); | |
} | |
console.log(resolutions); | |
//output of resolutions | |
/* | |
[ 156543.03392804097, | |
78271.51696402048, | |
39135.75848201024, | |
19567.87924100512, | |
9783.93962050256, | |
4891.96981025128, | |
2445.98490512564, | |
1222.99245256282, | |
611.49622628141, | |
305.748113140705, | |
152.8740565703525, | |
76.43702828517625, | |
38.21851414258813, | |
19.109257071294063, | |
9.554628535647032, | |
4.777314267823516, | |
2.388657133911758, | |
1.194328566955879, | |
0.5971642834779395, | |
0.29858214173896974, | |
0.14929107086948487, | |
0.07464553543474244, | |
0.03732276771737122, | |
0.01866138385868561 ] | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment