-
-
Save rlucha/df755cabd2c8c6547c105c828ccf2df0 to your computer and use it in GitHub Desktop.
convert from long/lat to google mercator (or EPSG:4326 to EPSG:900913)
This file contains 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
var degrees2meters = function(lon,lat) { | |
var x = lon * 20037508.34 / 180; | |
var y = Math.log(Math.tan((90 + lat) * Math.PI / 360)) / (Math.PI / 180); | |
y = y * 20037508.34 / 180; | |
return [x, y] | |
} | |
x= -77.035974 | |
y = 38.898717 | |
console.log(degrees2meters(x,y)) | |
// should result in: -8575605.398444, 4707174.018280 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment