Hi,
I want to find the distance between two locations on Google Maps given with their latitude and longitude in javascript. The latitude and longitude are in format double
Can anybody help me please?
Thanks
Hi,
I want to find the distance between two locations on Google Maps given with their latitude and longitude in javascript. The latitude and longitude are in format double
Can anybody help me please?
Thanks
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.
NelPosted Oct 22, 2014, 10:47 AM
Blocked AccountPosted Oct 22, 2014, 1:57 AM
You can find the distance between two latitude and longitude by using below code in javascript. This will give you air distance in miles.
<script type="text/javascript">
$(document).ready(function () {
var sourceLatitude =28.58;
var sourceLongitude = 77.329;
var destinationLatitude = 26.44;
var destinationLongitude = 80.331;
var value1 = Math.sqrt(Math.pow(69.1 * (destinationLatitude - sourceLatitude), 2) + Math.pow(69.1 * (sourceLongitude - destinationLongitude) * Math.cos(destinationLatitude / 57.3), 2))
alert(value1);
});
script>