A simple Node.js package to calculate the distance (in km) between two pincodes using the Nominatim OpenStreetMap API. This package is ideal for React, Angular, Node.js, and other JavaScript-based projects.
✅ Fetches latitude & longitude from a pincode
✅ Uses the Haversine formula to calculate distances
✅ Works with any JavaScript/Node.js project
✅ Lightweight and easy to use
You can install this package using NPM:
npm install pincode-distance-mapping
1. Import the package
In Node.js
const { getDistance, getCoordinates } = require('pincode-distance-mapping');
In ES Modules:
import { getDistance, getCoordinates } from 'pincode-distance-mapping';
2. Get Distance Between Two Pincodes
(async () => {
const distance = await getDistance("110001", "400001"); // Example: Delhi to Mumbai
console.log("Distance:", distance);
})();
getDistance(Source Pincode, Destination Pincode);