diff --git a/lib/OpenLayers/Spherical.js b/lib/OpenLayers/Spherical.js index 74e14a8c75..9f09a46324 100644 --- a/lib/OpenLayers/Spherical.js +++ b/lib/OpenLayers/Spherical.js @@ -60,8 +60,8 @@ OpenLayers.Spherical.computeDistanceBetween = function(from, to, radius) { * {Float} The heading in degrees. */ OpenLayers.Spherical.computeHeading = function(from, to) { - var y = Math.sin(Math.PI * (from.lon - to.lon) / 180) * Math.cos(Math.PI * to.lat / 180); + var y = Math.sin(Math.PI * (to.lon - from.lon) / 180) * Math.cos(Math.PI * to.lat / 180); var x = Math.cos(Math.PI * from.lat / 180) * Math.sin(Math.PI * to.lat / 180) - - Math.sin(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180) * Math.cos(Math.PI * (from.lon - to.lon) / 180); + Math.sin(Math.PI * from.lat / 180) * Math.cos(Math.PI * to.lat / 180) * Math.cos(Math.PI * (to.lon - from.lon) / 180); return 180 * Math.atan2(y, x) / Math.PI; };