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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Blocked AccountRank #403 · 6.2K reputationPosted Oct 21, 2014, 9:57 PM EDT
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>
NelRank #2,060 · 702 reputationPosted Oct 22, 2014, 6:47 AM EDT