Hello,
I've been searching on the forum but I didn't find the answer: can you help me on how to obtain the distance between two Location objects please?
Thank you!
Regards,
Marc
//
// distance between two location (meters) and returns formatted string
//
function computeDistance(lat1, lon1, lat2, lon2) {
var mlat,mlon;
var dx, dy, distance;
mlat = (lat1 + lat2) / 2 * 0.01745;
dx = 111.3 * Math.cos(mlat) * (lon1 - lon2);
dy = 111.3 * (lat1 - lat2);
distance = 1000 * Math.sqrt(dx * dx + dy * dy);
return distToStr(distance);
}