distance-calculator-openrouteservice
Version:
A free Node.js library to calculate distance between places using OpenRouteService.
68 lines (41 loc) • 1.51 kB
Markdown
# Abhinav Singh
# 🌍 distance-calculator-openrouteservice
A lightweight Node.js package to calculate the **distance** and **travel duration** between two real-world places using the free [OpenRouteService API](https://openrouteservice.org/).
> ✅ Supports travel by car, bike, walking, hiking, and even wheelchair routes!
## 🚀 Features
- 🌐 Calculates distance between **two places by name**
- ⏱️ Returns estimated **travel duration in minutes**
- 📦 Supports multiple **travel modes**
- 💬 Returns **detailed output** in JSON format
- 🆓 Uses free API from OpenRouteService
## 📦 Installation
```bash
npm install distance-calculator-openrouteservice
// test.js
import getDistance from 'distance-calculator-openrouteservice';
const run = async () => {
const result = await getDistance("New Delhi", "Mumbai", "driving-car");
console.log(result);
};
run();
##Sample output
{
"distance_km": 1400.32,
"duration_minutes": 1077,
"mode": "driving-car",
"from": "New Delhi",
"to": "Mumbai"
}
✅ Available Travel Modes
Mode Description
driving-car 🚗 Car on normal roads (default)
driving-hgv 🚚 Heavy goods vehicle (truck, lorry)
cycling-regular 🚲 Regular cycling
cycling-road 🚴 Road cycling
cycling-mountain 🚵 Mountain biking
cycling-electric ⚡ E-bike cycling
foot-walking 🚶 Walking
foot-hiking 🥾 Hiking/trail walking
wheelchair ♿ Wheelchair-optimized route