A small JavaScript library to calculate the qibla (direction to the kaaba in Mecca) from a given coordinate pair. Calculates using great-circle (default) or a rhumb line. Most of the code adaptions of the calculations in the source code are directly from or adapted from turf.js, however turf is not a dependency.
npm install asturlab
Available in AMD, CJS, IIFE (with compatible version down to IE10) and ES6 Module.
import asturlab from 'asturlab';
<script src="path/to/dist/asturlab-iife.min.js"></script>
const asturlab = require('asturlab');
const qibla = asturlab([32.123, 54.321]);
// qibla is now the bearing to the kaaba in degrees
asturlab(coordinates[, options]])
coordinates
is a [x,y] (long, lat) pair of decimal degree coordinates in WGS84
options
supported:
rhumb
- boolean, sets calculation to use rhumb line instead of great circle