{"id":69416,"date":"2026-11-04T09:52:42","date_gmt":"2026-11-04T04:22:42","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/tools\/distance-calculator\/"},"modified":"2026-11-04T09:52:42","modified_gmt":"2026-11-04T04:22:42","slug":"distance-calculator","status":"publish","type":"page","link":"https:\/\/www.quickonlinetips.com\/archives\/tools\/distance-calculator\/","title":{"rendered":"Distance Calculator: Straight-Line Distance Between Two Places"},"content":{"rendered":"<p>This free <strong>distance calculator<\/strong> finds the distance between two places in kilometres and miles. Enter GPS coordinates (or use your location) to get the exact <strong>straight-line distance, as the crow flies<\/strong>, with the compass direction and the halfway point. Type two place names instead to see the driving, walking or cycling route and distance on a Google map.<\/p>\n<div class=\"qt-tool\" id=\"qt-dst\">\n<p class=\"qt-label\" style=\"font-size:1.15em;margin:0 0 10px\"><strong>Step 1:<\/strong> Enter the two places<\/p>\n<p> <label class=\"qt-label\" for=\"qt-dst-a\" style=\"color:#174ea6\">From (place A)<\/label> <\/p>\n<div class=\"qt-row\" style=\"margin-top:0\"><input type=\"text\" id=\"qt-dst-a\" placeholder=\"e.g. 40.7128, -74.0060 or New York, NY\" maxlength=\"120\" autocomplete=\"off\" style=\"flex:1 1 240px\"><button type=\"button\" class=\"qt-btn qt-btn-ghost\" id=\"qt-dst-mea\">Use my location<\/button><\/div>\n<p> <label class=\"qt-label qtx-h\" for=\"qt-dst-b\" style=\"color:#174ea6\">To (place B)<\/label> <\/p>\n<div class=\"qt-row\" style=\"margin-top:0\"><input type=\"text\" id=\"qt-dst-b\" placeholder=\"e.g. 34.0522, -118.2437 or Los Angeles, CA\" maxlength=\"120\" autocomplete=\"off\" style=\"flex:1 1 240px\"><button type=\"button\" class=\"qt-btn qt-btn-ghost\" id=\"qt-dst-meb\">Use my location<\/button><\/div>\n<p class=\"qt-small\" style=\"text-align:left;font-size:14px\">Coordinates give an exact straight-line answer here. Place names are looked up by Google Maps when you press the button.<\/p>\n<p class=\"qt-label\" style=\"font-size:1.15em;margin:18px 0 10px\"><strong>Step 2:<\/strong> Choose how to measure<\/p>\n<div class=\"qtx-chipset\" role=\"group\" aria-label=\"How to measure\"><button type=\"button\" data-m=\"flying\" aria-pressed=\"true\">Straight line (as the crow flies)<\/button><button type=\"button\" data-m=\"driving\" aria-pressed=\"false\">Driving<\/button><button type=\"button\" data-m=\"walking\" aria-pressed=\"false\">Walking<\/button><button type=\"button\" data-m=\"bicycling\" aria-pressed=\"false\">Cycling<\/button><\/div>\n<div class=\"qt-grid\" style=\"max-width:320px\">\n<div class=\"qt-field\"><label for=\"qt-dst-u\">Show first in<\/label><select id=\"qt-dst-u\"><option value=\"mi\">Miles<\/option><option value=\"km\">Kilometres<\/option><\/select><\/div>\n<\/div>\n<p class=\"qt-label\" style=\"font-size:1.15em;margin:18px 0 10px\"><strong>Step 3:<\/strong> Press Find distance<\/p>\n<p> <button type=\"button\" class=\"qt-btn qt-btn-big\" id=\"qt-dst-go\" style=\"width:100%\">Find distance<\/button> <\/p>\n<p class=\"qt-status\" id=\"qt-dst-status\" aria-live=\"polite\">\n<div id=\"qt-dst-res\" class=\"qtx-out\" hidden>\n<p class=\"qt-label\" style=\"margin:0\">Straight-line distance<\/p>\n<p class=\"qtx-big-out\" id=\"qt-dst-big\">\n<table class=\"qtx-kv\">\n<tbody>\n<tr>\n<th>Kilometres<\/th>\n<td id=\"qt-dst-km\"><\/td>\n<\/tr>\n<tr>\n<th>Miles<\/th>\n<td id=\"qt-dst-mi\"><\/td>\n<\/tr>\n<tr>\n<th>Nautical miles<\/th>\n<td id=\"qt-dst-nm\"><\/td>\n<\/tr>\n<tr>\n<th>Direction from A to B<\/th>\n<td id=\"qt-dst-brg\"><\/td>\n<\/tr>\n<tr>\n<th>Halfway point<\/th>\n<td id=\"qt-dst-mid\"><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div class=\"qt-row\"><button type=\"button\" class=\"qt-btn qt-btn-ghost\" id=\"qt-dst-copy\">Copy result<\/button><span class=\"qt-status\" id=\"qt-dst-copied\" aria-live=\"polite\" style=\"margin:0\"><\/span><\/div>\n<div class=\"qtx-links\" id=\"qt-dst-links\"><\/div>\n<\/div>\n<div class=\"qtx-mapph\" id=\"qt-dst-ph\"><b>&#x1F5FA;<\/b><span>Your map will appear here after you press <strong>Find distance<\/strong>.<\/span><\/div>\n<p> <iframe class=\"qtx-map\" id=\"qt-dst-map\" title=\"Map of the route between the two places\" width=\"600\" height=\"440\" loading=\"lazy\" allowfullscreen referrerpolicy=\"no-referrer-when-downgrade\" hidden><\/iframe> <\/p>\n<div class=\"qt-row\" id=\"qt-dst-more\" style=\"margin:14px 0 0\"><\/div>\n<p class=\"qt-note\"><strong>Private by design:<\/strong> straight-line distances are worked out in your browser. Your location is used only if you press Use my location. When you press Find distance, the two places go only to Google Maps to draw the map, never to QuickOnlineTips, and nothing is stored. Map data &copy; Google. QuickOnlineTips is not affiliated with Google.<\/p>\n<\/p><\/div>\n<p><script>(function () { function qtReady(fn) { if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', fn); } else { fn(); } } function qtCopy(text, statusEl, okMsg) { function done(ok) { if (statusEl) { statusEl.textContent = ok ? (okMsg || 'Copied to clipboard.') : 'Press Ctrl+C (or Cmd+C) to copy.'; } } function fallback() { var ta = document.createElement('textarea'); ta.value = text; ta.setAttribute('readonly', ''); ta.style.position = 'fixed'; ta.style.top = '-1000px'; document.body.appendChild(ta); ta.select(); var ok = false; try { ok = document.execCommand('copy'); } catch (e) { ok = false; } document.body.removeChild(ta); done(ok); } if (navigator.clipboard) { if (window.isSecureContext) { navigator.clipboard.writeText(text).then(function () { done(true); }, fallback); return; } } fallback(); } function qtSave(blob, name) { var a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = name; document.body.appendChild(a); a.click(); setTimeout(function () { URL.revokeObjectURL(a.href); a.remove(); }, 1500); } qtReady(function () { var root = document.getElementById('qt-dst'); if (!root) { return; } var A = String.fromCharCode(38); function $(id) { return document.getElementById('qt-dst-' + id); } var KEY = 'AIzaSyCDmjrz5MNeMPqksCFVoqK6AunPPfv22rk', EMB = 'https:\/\/www.google.com\/maps\/embed\/v1\/directions?key=' + KEY; var aIn = $('a'), bIn = $('b'), st = $('status'), res = $('res'), mapEl = $('map'), ph = $('ph'), more = $('more'), uEl = $('u'); var chips = root.querySelectorAll('[data-m]'), mode = 'flying', last = ''; try { if ((navigator.language || '').indexOf('US') === -1) { if ((navigator.language || '').indexOf('en-GB') === -1) { uEl.value = 'km'; } } } catch (e) { } function say(t, bad) { st.textContent = t; st.classList.toggle('qt-error', !!bad); } Array.prototype.forEach.call(chips, function (b) { b.addEventListener('click', function () { mode = b.getAttribute('data-m'); Array.prototype.forEach.call(chips, function (x) { x.setAttribute('aria-pressed', x === b ? 'true' : 'false'); }); }); }); function parse(v) { v = (v || '').trim(); if (!v) { return null; } var nums = v.replace(\/,\/g, ' ').split(\/\\s+\/).filter(function (x) { return x.length; }); if (nums.length === 2) { if (\/^-?\\d+(\\.\\d+)?$\/.test(nums[0])) { if (\/^-?\\d+(\\.\\d+)?$\/.test(nums[1])) { var la = parseFloat(nums[0]), lo = parseFloat(nums[1]); if (90 >= Math.abs(la)) { if (180 >= Math.abs(lo)) { return [la, lo]; } } return 'range'; } } } var re = \/(\\d+(?:\\.\\d+)?)\\s*[\u00b0d\\s]\\s*(\\d+(?:\\.\\d+)?)?\\s*['\u2032m]?\\s*(\\d+(?:\\.\\d+)?)?\\s*[\"\u2033s]?\\s*([NSEWnsew])\/g, out = [], m; while ((m = re.exec(v)) !== null) { var dd = parseFloat(m[1]) + (parseFloat(m[2] || 0) \/ 60) + (parseFloat(m[3] || 0) \/ 3600); if ('SWsw'.indexOf(m[4]) > -1) { dd = -dd; } out.push([dd, 'NSns'.indexOf(m[4]) > -1]); } if (out.length === 2) { var lat = out[0][1] ? out[0][0] : out[1][0], lon = out[0][1] ? out[1][0] : out[0][0]; return [lat, lon]; } return null; } function rad(d) { return d * Math.PI \/ 180; } function deg(r) { return r * 180 \/ Math.PI; } function hav(p, q) { var R = 6371.0088, dLa = rad(q[0] - p[0]), dLo = rad(q[1] - p[1]), x = Math.sin(dLa \/ 2) * Math.sin(dLa \/ 2) + Math.cos(rad(p[0])) * Math.cos(rad(q[0])) * Math.sin(dLo \/ 2) * Math.sin(dLo \/ 2); return 2 * R * Math.atan2(Math.sqrt(x), Math.sqrt(1 - x)); } function bearing(p, q) { var y = Math.sin(rad(q[1] - p[1])) * Math.cos(rad(q[0])), x = Math.cos(rad(p[0])) * Math.sin(rad(q[0])) - Math.sin(rad(p[0])) * Math.cos(rad(q[0])) * Math.cos(rad(q[1] - p[1])); return (deg(Math.atan2(y, x)) + 360) % 360; } function midpoint(p, q) { var la1 = rad(p[0]), lo1 = rad(p[1]), la2 = rad(q[0]), dLo = rad(q[1] - p[1]), bx = Math.cos(la2) * Math.cos(dLo), by = Math.cos(la2) * Math.sin(dLo); var la = Math.atan2(Math.sin(la1) + Math.sin(la2), Math.sqrt((Math.cos(la1) + bx) * (Math.cos(la1) + bx) + by * by)), lo = lo1 + Math.atan2(by, Math.cos(la1) + bx); return [deg(la), ((deg(lo) + 540) % 360) - 180]; } var PTS = ['N', 'NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW']; function nf(n, d) { return n.toLocaleString(undefined, { minimumFractionDigits: d, maximumFractionDigits: d }); } function dp(n) { return 10 > n ? 2 : (100 > n ? 1 : 0); } function link(box, text, href) { var a = document.createElement('a'); a.href = href; a.target = '_blank'; a.rel = 'nofollow noopener noreferrer'; a.textContent = text; box.appendChild(a); } function me(input, btn) { btn.addEventListener('click', function () { if (!navigator.geolocation) { say('Your browser cannot share your location. Type coordinates instead.', true); return; } btn.disabled = true; say('Asking your browser for your location...'); navigator.geolocation.getCurrentPosition(function (pos) { btn.disabled = false; input.value = pos.coords.latitude.toFixed(6) + ', ' + pos.coords.longitude.toFixed(6); say('Location added. Now fill in the other place, then press Find distance.'); }, function (err) { btn.disabled = false; say(err.code === 1 ? 'Location permission was blocked. Allow location for this site, or type coordinates.' : 'Could not get your location. Type coordinates instead.', true); }, { enableHighAccuracy: true, timeout: 15000, maximumAge: 60000 }); }); } me(aIn, $('mea')); me(bIn, $('meb')); function clean(v) { v = (v || '').trim(); if (v.length > 120) { v = v.slice(0, 120); } return v; } $('go').addEventListener('click', function () { var av = clean(aIn.value), bv = clean(bIn.value); if (!av) { say('Step 1 first: type place A, or press Use my location.', true); aIn.focus(); return; } if (!bv) { say('Step 1 first: type place B.', true); bIn.focus(); return; } var p = parse(av), q = parse(bv); if (p === 'range' || q === 'range') { say('Latitude must be between -90 and 90, and longitude between -180 and 180.', true); return; } var both = (p !== null) * (q !== null), mi = uEl.value === 'mi'; res.hidden = true; $('copied').textContent = ''; if (both) { var km = hav(p, q), b = bearing(p, q), m = midpoint(p, q), miles = km \/ 1.609344, nm = km \/ 1.852; $('big').textContent = mi ? nf(miles, dp(miles)) + ' miles (' + nf(km, dp(km)) + ' km)' : nf(km, dp(km)) + ' km (' + nf(miles, dp(miles)) + ' miles)'; $('km').textContent = nf(km, 3) + ' km'; $('mi').textContent = nf(miles, 3) + ' mi'; $('nm').textContent = nf(nm, 3) + ' nmi'; $('brg').textContent = Math.round(b) + '\u00b0 (' + PTS[Math.round(b \/ 22.5) % 16] + ')'; $('mid').textContent = m[0].toFixed(6) + ', ' + m[1].toFixed(6); var box = $('links'); box.textContent = ''; link(box, 'Open the halfway point in Google Maps', 'https:\/\/www.google.com\/maps\/search\/?api=1' + A + 'query=' + m[0].toFixed(6) + ',' + m[1].toFixed(6)); link(box, 'Places to meet near the halfway point', 'https:\/\/www.google.com\/maps\/search\/restaurants\/@' + m[0].toFixed(6) + ',' + m[1].toFixed(6) + ',13z'); last = 'From ' + av + ' to ' + bv + ': ' + $('big').textContent + ' in a straight line. Direction ' + $('brg').textContent + '. Halfway point ' + $('mid').textContent + '.'; res.hidden = false; } var o = p ? p[0] + ',' + p[1] : av, d = q ? q[0] + ',' + q[1] : bv; mapEl.src = EMB + A + 'origin=' + encodeURIComponent(o) + A + 'destination=' + encodeURIComponent(d) + A + 'mode=' + mode + A + 'units=' + (mi ? 'imperial' : 'metric'); mapEl.hidden = false; ph.hidden = true; more.textContent = ''; var gm = document.createElement('a'); gm.className = 'qt-btn qt-btn-ghost'; gm.target = '_blank'; gm.rel = 'nofollow noopener noreferrer'; gm.textContent = 'Open in the Google Maps app'; gm.href = 'https:\/\/www.google.com\/maps\/dir\/?api=1' + A + 'origin=' + encodeURIComponent(o) + A + 'destination=' + encodeURIComponent(d) + (mode === 'flying' ? '' : A + 'travelmode=' + mode); more.appendChild(gm); if (both) { say(mode === 'flying' ? 'Done. The straight-line distance is below; the map shows the line.' : 'Done. The straight-line distance is below; the map shows the ' + (mode === 'bicycling' ? 'cycling' : mode) + ' route and its distance.'); } else { say(mode === 'flying' ? 'The map shows the straight line between the two places. For an exact number here, enter both places as coordinates.' : 'The map shows the ' + (mode === 'bicycling' ? 'cycling' : mode) + ' route. The distance and time are shown on the map.'); } }); [aIn, bIn].forEach(function (el) { el.addEventListener('keydown', function (e) { if (e.key === 'Enter') { e.preventDefault(); $('go').click(); } }); }); $('copy').addEventListener('click', function () { if (last) { qtCopy(last, $('copied'), 'Result copied.'); } else { $('copied').textContent = 'Press Find distance first.'; } }); }); })();<\/script><\/p>\n<div class=\"qt-next\">\n<p class=\"qt-next-h\">Try another free tool<\/p>\n<div class=\"qt-next-g\"><a href=\"https:\/\/www.quickonlinetips.com\/archives\/tools\/my-location\/\">My Location<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/tools\/near-me-finder\/\">Near Me Finder<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/tools\/length-converter\/\">Length Converter<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/tools\/time-zone-converter\/\">Time Zone Converter<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/tools\/photo-location-finder\/\">Photo Location Finder<\/a><a href=\"https:\/\/www.quickonlinetips.com\/archives\/tools\/gas-station-near-me\/\">Gas Station Finder<\/a><\/div>\n<\/div>\n<p><strong>Quick answer:<\/strong> Type two sets of coordinates (or press <strong>Use my location<\/strong> for one of them), keep <strong>Straight line<\/strong> selected and press <strong>Find distance<\/strong>. You get the distance as the crow flies in kilometres, miles and nautical miles, the compass direction and the halfway point. For road distance, type place names and choose <strong>Driving<\/strong>.<\/p>\n<h2>How to find the distance between two places<\/h2>\n<ol>\n<li>In <strong>From<\/strong> and <strong>To<\/strong>, type coordinates such as <code>40.7128, -74.0060<\/code>, coordinates in degrees, minutes and seconds, or a place name or address. Press <strong>Use my location<\/strong> to fill in where you are now.<\/li>\n<li>Choose <strong>Straight line<\/strong> for the direct distance, or <strong>Driving<\/strong>, <strong>Walking<\/strong> or <strong>Cycling<\/strong> for a route.<\/li>\n<li>Press <strong>Find distance<\/strong>. With coordinates you get exact numbers below the button. The map shows the line or route; for routes, the distance and travel time are shown on the map.<\/li>\n<\/ol>\n<p>Tip: to get the coordinates of any spot, open Google Maps on a computer, right-click the spot and click the numbers at the top of the menu to copy them. On a phone, press and hold the spot. Our <a href=\"https:\/\/www.quickonlinetips.com\/archives\/tools\/my-location\/\">My Location<\/a> tool shows your own coordinates.<\/p>\n<h2>What does &#8220;as the crow flies&#8221; mean?<\/h2>\n<p>It means the shortest distance over the surface of the Earth between two points, ignoring roads, rivers and mountains. This is also called the great-circle distance. It is what pilots, sailors and radio users plan with, and it is always shorter than the road distance. Road trips are usually 20 to 40 percent longer than the straight line.<\/p>\n<h2>How the distance is calculated<\/h2>\n<p>The tool uses the haversine formula on a sphere with the Earth&#8217;s mean radius of 6,371 km (3,958.8 miles). This is accurate to within about 0.5 percent anywhere on Earth, which is a few kilometres on a very long flight and a few metres across a city. The direction is the initial compass bearing from A towards B, and the halfway point is the point on the great circle midway between them.<\/p>\n<h2>FAQ<\/h2>\n<h3>Why does the straight-line distance differ from the driving distance?<\/h3>\n<p>Roads bend around hills, water and buildings, so a drive is always longer than the straight line. Choose Driving to see the actual road route and its length on the map.<\/p>\n<h3>Can I find the halfway point between two cities?<\/h3>\n<p>Yes. Enter both as coordinates and the result shows the halfway point, with a link to open it on a map so you can look for a place to meet.<\/p>\n<h3>Is my location shared?<\/h3>\n<p>Only if you press Use my location, and then only inside your browser. Coordinates and place names go to Google Maps when you press Find distance so the map can be drawn. QuickOnlineTips never receives them.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This free distance calculator finds the distance between two places in kilometres and miles. Enter GPS coordinates (or use your location) to get the exact straight-line distance, as the crow flies, with the compass direction and the halfway point. Type two place names instead to see the driving, walking or cycling route and distance on&#8230;<\/p>\n","protected":false},"author":7,"featured_media":0,"parent":65595,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"class_list":["post-69416","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/pages\/69416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=69416"}],"version-history":[{"count":0,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/pages\/69416\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/pages\/65595"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=69416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}