Created
April 4, 2017 07:09
-
-
Save duzvik/9d63127a2b086fe95bb6499bb7e32d1b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| The math is described at: | |
| http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ | |
| …including the source code for command line utility and an online demonstration. | |
| It is also pretty simple math: | |
| function tile2long(x,z) { return (x/Math.pow(2,z)*360-180); } | |
| function tile2lat(y,z) { | |
| var n=Math.PI-2*Math.PI*y/Math.pow(2,z); | |
| return (180/Math.PI*Math.atan(0.5*(Math.exp(n)-Math.exp(-n)))); | |
| } | |
| Note the difference between XYZ/Google vs TMS in y axis. | |
| Google Maps API V3 gives you the required functions too via .fromPointToLatLng() of map.getProjection(). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment