Skip to content

Instantly share code, notes, and snippets.

@dgalli1
Last active June 15, 2021 19:29
Show Gist options
  • Save dgalli1/b5837bdf3c32b8f1dd994172dea3eb14 to your computer and use it in GitHub Desktop.
Save dgalli1/b5837bdf3c32b8f1dd994172dea3eb14 to your computer and use it in GitHub Desktop.
Download all Tiles from Google Maps Mars
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