GetQibla

How Qibla direction is calculated

GetQibla calculates the initial great-circle bearing from your coordinates to the Kaaba at 21.4224779° N, 39.8251832° E. The result is a clockwise angle from true north. On supported phones, that angle is compared with the device heading to rotate the arrow.

The calculation

The latitude and longitude of both points are converted to radians. Spherical trigonometry gives the initial bearing of the shortest route over the Earth’s surface. The result is normalized to a value from 0° to less than 360°.

What runs on the device

The browser requests your coordinates and reads orientation events when available. GetQibla performs the bearing and arrow calculations in browser JavaScript. The open-source project does not send those readings to an application server.

Accuracy limits

The mathematical bearing is deterministic for the supplied coordinates. The live arrow can still be affected by location accuracy, magnetic declination, sensor calibration, tilt, metal, magnets and browser differences. GetQibla does not claim perfect compass accuracy.

Open test data

The project publishes calculation tests and a machine-readable city bearing dataset so results can be checked independently.

Sources and verification

Open the Qibla compass