calculate distance between two or more points on Google Maps
how to calculate distance between two or more points using google maps in c# asp .net?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Joicy SunnyPosted May 17, 2017, 6:55 AM
rajeev kumarPosted May 17, 2017, 6:52 AM
Rajkiran SwainPosted May 17, 2017, 6:34 AM
{
return x * Math.PI / 180;
};
var getDistance = function(p1, p2)
{
var R = 6378137; // Earth’s mean radius in meter
var dLat = rad(p2.lat() - p1.lat());
var dLong = rad(p2.lng() - p1.lng());
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) *
Math.sin(dLong / 2) * Math.sin(dLong / 2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
var d = R * c;
return d; // returns the distance in meter
};