Free developer tool
Distance Calculator
Calculate road distance and estimated travel time between two coordinates. Choose a travel mode, or click the map to set the origin and destination.
Road distance, time and the route line appear here.
Address and road data © OpenStreetMap contributors (ODbL) and other open datasets.
Road distance vs. straight-line distance
A straight-line distance measures the shortest path over the Earth's surface between two points. A routing engine follows the road network instead, so its result is normally longer and far more useful for deliveries, fleet operations and travel estimates.
What can you calculate?
The route endpoint returns distance, duration and the route geometry for driving, cycling, walking and motor-scooter scenarios. For many-to-many calculations use the Matrix API.
Frequently asked questions
What is the difference between road and straight-line distance?
Straight-line (great-circle) distance ignores roads and is always the shortest. Road distance follows the network and is what drivers, couriers and cyclists actually travel. The result panel shows both so you can see the difference.
Does the route account for live traffic?
No. Durations are estimates based on the road network and travel mode, not live traffic conditions.
What if I need many origins and destinations?
Use the Matrix API, which returns distances and durations for many origin and destination pairs in one request.
API
Calculate road distance with the API
POST /v1/routecurl -X POST \
-H "Content-Type: application/json" \
-H "X-API-Key: YOUR_MAPSI_API_KEY" \
https://mapsi.dev/v1/route \
-d '{"origin":{"lat":51.5033635,"lon":-0.1276248},"destination":{"lat":51.5079,"lon":-0.0877},"mode":"auto","units":"km"}'const response = await fetch("https://mapsi.dev/v1/route", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": "YOUR_MAPSI_API_KEY"
},
body: JSON.stringify({
"origin": {
"lat": 51.5033635,
"lon": -0.1276248
},
"destination": {
"lat": 51.5079,
"lon": -0.0877
},
"mode": "auto",
"units": "km"
})
});
const data = await response.json();
console.log(data.distance_km, data.duration_sec);import requests
response = requests.post(
"https://mapsi.dev/v1/route",
headers={"X-API-Key": "YOUR_MAPSI_API_KEY"},
json={
"origin": {
"lat": 51.5033635,
"lon": -0.1276248
},
"destination": {
"lat": 51.5079,
"lon": -0.0877
},
"mode": "auto",
"units": "km"
},
)
data = response.json()
print(data){
"success": true,
"waypoint_count": 2,
"distance_km": 4.15,
"duration_sec": 512,
"legs": [{ "from": 0, "to": 1, "distance_km": 4.15, "duration_sec": 512 }],
"polyline": {
"type": "LineString",
"coordinates": [[-0.127645, 51.503251], [-0.127566, 51.503246], ...]
}
}