Last active
December 16, 2015 10:59
-
-
Save bryanbuchanan/5424543 to your computer and use it in GitHub Desktop.
Function that takes latitude/longitude of a single point and returns x/y position as plotted on an equirectangular map.
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
// Function | |
function lltoXY(options) { | |
var x = (options.lon + 180) * (options.width / 360); | |
var y = ((options.lat * -1) + 90) * (options.height / 180); | |
return { x: x, y: y }; | |
} | |
// Usage | |
var position = lltoXY({ | |
lat: 25.26, | |
lon: 55.3, | |
width: 300, | |
height: 200 | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment