Skip to content

Instantly share code, notes, and snippets.

@bryanbuchanan
Last active December 16, 2015 10:59
Show Gist options
  • Save bryanbuchanan/5424543 to your computer and use it in GitHub Desktop.
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.
// 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