Calculate Distance Google Maps

Google Maps Coordinates Distance Calculator

Calculate the "as the crow flies" distance between two sets of GPS coordinates using the Haversine formula.

Point A (Origin)

Point B (Destination)

Calculated Distance:

0.00
Kilometers
0.00
Miles
0.00
Nautical Miles
function calculateMapDistance() { var lat1 = parseFloat(document.getElementById('lat1').value); var lon1 = parseFloat(document.getElementById('lon1').value); var lat2 = parseFloat(document.getElementById('lat2').value); var lon2 = parseFloat(document.getElementById('lon2').value); if (isNaN(lat1) || isNaN(lon1) || isNaN(lat2) || isNaN(lon2)) { alert("Please enter valid numeric coordinates for both points."); return; } if (lat1 90 || lat2 90 || lon1 180 || lon2 180) { alert("Latitude must be between -90 and 90. Longitude must be between -180 and 180."); return; } var R = 6371; // Radius of Earth in kilometers var dLat = (lat2 – lat1) * Math.PI / 180; var dLon = (lon2 – lon1) * Math.PI / 180; var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) * Math.sin(dLon / 2) * Math.sin(dLon / 2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 – a)); var distanceKm = R * c; var distanceMi = distanceKm * 0.621371; var distanceNm = distanceKm * 0.539957; document.getElementById('kmResult').innerHTML = distanceKm.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}); document.getElementById('miResult').innerHTML = distanceMi.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}); document.getElementById('nmResult').innerHTML = distanceNm.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}); document.getElementById('resultContainer').style.display = 'block'; }

How to Calculate Distance Between Coordinates

When you use Google Maps to find the distance between two points, the app usually provides the travel distance via roads. However, for aviation, marine navigation, or scientific research, you often need the Great Circle Distance—the shortest path between two points on the surface of a sphere.

The Haversine Formula

This calculator uses the Haversine formula to account for the Earth's curvature. Because the Earth is not flat, a simple Pythagorean calculation would result in significant errors over long distances. The formula is as follows:

a = sin²(Δφ/2) + cos φ1 ⋅ cos φ2 ⋅ sin²(Δλ/2)
c = 2 ⋅ atan2( √a, √(1−a) )
d = R ⋅ c

Where φ is latitude, λ is longitude, and R is Earth's mean radius (6,371 km).

Example Calculation: New York to Los Angeles

To see the calculator in action, let's look at a real-world example of calculating the distance between major hubs:

Location Latitude Longitude
New York (JFK) 40.6413° N 73.7781° W
Los Angeles (LAX) 33.9416° N 118.4085° W

The straight-line distance (displacement) between these two points is approximately 3,982 kilometers (2,474 miles). Note that a commercial flight path might be longer due to air traffic control and jet streams.

Frequently Asked Questions

Is this the same as Google Maps driving distance?

No. This tool calculates the straight-line distance. Driving distance is always longer because it follows the geometry of roads and terrain.

How accurate is this calculator?

The Haversine formula is accurate to within 0.5% for most calculations. The slight error occurs because the Earth is an oblate spheroid (slightly flattened at the poles) rather than a perfect sphere.

What are Decimal Degrees (DD)?

Our calculator requires Decimal Degrees. If you have coordinates in Degrees, Minutes, Seconds (DMS), you must convert them. For example, 40° 42′ 46″ N becomes 40.7128.

Leave a Comment