Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distance Between Two GEO Locations [duplicate]

Tags:

javascript

I have two GEO locations. How can I calculate the distance between them?

like image 667
Lennie Avatar asked Oct 01 '10 10:10

Lennie


People also ask

How do you find the distance between two geo points?

For this divide the values of longitude and latitude of both the points by 180/pi. The value of pi is 22/7. The value of 180/pi is approximately 57.29577951. If we want to calculate the distance between two places in miles, use the value 3, 963, which is the radius of Earth.

What is the distance between 2 latitudes?

What is the distance between two latitudes? The distance between any two latitudes is approximately 69 miles or 111 km. Latitude lines run parallel to each other. That's why the distance between them remains constant from the South to the North pole.

How do I calculate distance between GPS coordinates in Excel?

Here are the formulas for degree coordinates: Cell B5: =distvincenty(B2,C2,B3,C3) Cell D5: =MOD(DEGREES(ATAN2(COS(B2*PI()/180) *SIN(B3*PI()/180)-SIN(B2*PI()/180) *COS(B3*PI()/180) *COS(C3*PI()/180-C2*PI()/180), SIN(C3*PI()/180-C2*PI()/180) *COS(B2*PI()/180)))+360,360)


1 Answers

If you use the Google Maps API v3 you can calculate the distance as follows:

Include the Google Maps JavaScript file with the geometry library:

http://maps.google.com/maps/api/js?sensor=true&libraries=geometry

The distance can be measured now by using the computeDistanceBetween() method:

var from = new google.maps.LatLng(49.004, 8.456);
var to   = new google.maps.LatLng(49.321, 8.789);
var dist = google.maps.geometry.spherical.computeDistanceBetween(from, to);
like image 78
powtac Avatar answered Oct 18 '22 05:10

powtac