Last active
June 15, 2021 19:29
-
-
Save dgalli1/b5837bdf3c32b8f1dd994172dea3eb14 to your computer and use it in GitHub Desktop.
Download all Tiles from Google Maps Mars
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 getMapUrl(tile, zoom) { | |
var bound = Math.pow(2, zoom); | |
var x = tile.x; | |
var y = tile.y; | |
// Don't repeat across y-axis (vertically). | |
if (y < 0 || y >= bound) { | |
return null; | |
} | |
// Repeat across x-axis. | |
if (x < 0 || x >= bound) { | |
x = (x % bound + bound) % bound; | |
} | |
var qstr = 't'; | |
for (var z = 0; z < zoom; z++) { | |
bound = bound / 2; | |
if (y < bound) { | |
if (x < bound) { | |
qstr += 'q'; | |
} else { | |
qstr += 'r'; | |
x -= bound; | |
} | |
} else { | |
if (x < bound) { | |
qstr += 't'; | |
y -= bound; | |
} else { | |
qstr += 's'; | |
x -= bound; | |
y -= bound; | |
} | |
} | |
} | |
return 'https://mw1.google.com/mw-planetary/mars/visible' + '/' + qstr + '.jpg'; | |
} | |
for (let x = 0; x < 256; x++) { | |
for (let y = 0; y < 256; y++) { | |
console.log(getMapUrl({ | |
x, | |
y | |
},8)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment