Skip to content

Instantly share code, notes, and snippets.

@Scarysize
Created October 24, 2016 17:59
Show Gist options
  • Select an option

  • Save Scarysize/7a30cbc88ba7c3d56921a527385d6950 to your computer and use it in GitHub Desktop.

Select an option

Save Scarysize/7a30cbc88ba7c3d56921a527385d6950 to your computer and use it in GitHub Desktop.
function unproject(point, zoom) {
return {
lng: xLng(point.x, zoom),
lat: yLat(point.y, zoom)
};
}
function xLng(x, zoom) {
return x * 360 / Math.pow(2, zoom) - 180;
}
function yLat(y, zoom) {
const y2 = 180 - y * 360 / Math.pow(2, zoom);
return 360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment