Created
January 15, 2018 19:35
-
-
Save clesauln/59ac090e16e9f0178018e67b47041757 to your computer and use it in GitHub Desktop.
convert rad to tiles js
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
Math.radians = function(degrees) { | |
return degrees * Math.PI / 180; | |
}; | |
var zoom = 8; | |
var lon = 5.2206592; | |
var lat = 49.1154095; | |
var xtile = Math.floor(((lon+180)/360) * Math.pow(2,zoom)); | |
var ytile = Math.floor((1- Math.log(Math.atan(Math.radians(lat)) + 1 / Math.cos(Math.radians(lat))) / Math.PI) / 2 * Math.pow(2,zoom)); | |
console.log('xtile: ' + xtile); | |
console.log('ytile: ' + ytile); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment