Skip to content

Instantly share code, notes, and snippets.

@jpoehnelt
Last active October 9, 2019 22:09
Show Gist options
  • Save jpoehnelt/efa60356ae407bd126e1a9c3f9ba7797 to your computer and use it in GitHub Desktop.
Save jpoehnelt/efa60356ae407bd126e1a9c3f9ba7797 to your computer and use it in GitHub Desktop.
var EXTENT = [-Math.PI * 6378137, Math.PI * 6378137];
function xyzToBounds(x, y, z) {
var tileSize = EXTENT[1] * 2 / Math.pow(2, z);
var minx = EXTENT[0] + x * tileSize;
var maxx = EXTENT[0] + (x + 1) * tileSize;
// remember y origin starts at top
var miny = EXTENT[1] - (y + 1) * tileSize;
var maxy = EXTENT[1] - y * tileSize;
return [minx, miny, maxx, maxy];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment