Haversine formula in JavaScript

var lat2 = Math.asin( Math.sin(lat1)Math.cos(d/R) + Math.cos(lat1)Math.sin(d/R)*Math.cos(brng) );

var lon2 = lon1 + Math.atan2(Math.sin(brng)Math.sin(d/R)Math.cos(lat1), Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));

Calculate distance and bearing between two Latitude/Longitude points using Haversine formula in JavaScript

Given a start point, initial bearing, and distance, this will calculate the destination point and final bearing travelling along a (shortest distance) great circle arc:

var lat2 = Math.asin( Math.sin(lat1)*Math.cos(d/R) + 
                      Math.cos(lat1)*Math.sin(d/R)*Math.cos(brng) );
var lon2 = lon1 + Math.atan2(Math.sin(brng)*Math.sin(d/R)*Math.cos(lat1), 
                             Math.cos(d/R)-Math.sin(lat1)*Math.sin(lat2));

Calculate distance and bearing between two Latitude/Longitude points using Haversine formula in JavaScript