Qibla Direction
{{ bearingDisplay }}
{{ summaryDirectionLine }}
Lat {{ formatCoord(latitude) }}, Long {{ formatCoord(longitude) }}
{{ currentLocationLabel }} {{ selectedDistanceDisplay }} {{ centralAngleDisplay }} Mag {{ magneticHeadingDisplay }} Earth {{ earthModelLabel }}
Current location tag: {{ currentLocationLabel }}
IP-based coordinates

Auto-detects your current public IP and applies the reported latitude/longitude.

Last update: {{ ipLookup.lastSuccess }}

{{ ipLookup.error }}
Device GPS

Requests precise coordinates from your browser or phone. Grant permission when prompted for the most accurate heading.

Last fix: {{ gpsLookup.lastSuccess }}

{{ gpsLookup.error }}
World city search

Results are limited to 10 per query. Selecting a row updates the coordinates above.

Enter at least two characters to search.
No matches yet—try a different spelling.
{{ citySearchError }}
Map picker

Click the map or drag the marker to update the coordinates. Use the buttons to sync the map center or reset the view.

Map data © contributors.

Manual coordinates
Lat °
{{ latitudeSliderLabel }}°
Long °
{{ longitudeSliderLabel }}°
Current location overview

Always reflects the coordinates in the fields above.

{{ formatCoord(latitude) }}, {{ formatCoord(longitude) }}
km
°
Qibla Compass
{{ currentLocationLabel || 'Custom coordinates' }}
Lat {{ formatCoord(latitude) }} • Long {{ formatCoord(longitude) }}
Facing instructions

{{ compassInstructionLong }}

  • True bearing: {{ bearingDisplay }} ({{ cardinalDirection }})
  • Magnetic heading: {{ magneticHeadingDisplay }} after applying {{ magneticDeclinationDisplay }}
  • Magnetic heading matches the true bearing when declination is 0°.
  • Great-circle distance: {{ distanceBreakdown.km }}
Sun alignment cues

{{ sunAlignmentNote }}

  • {{ event.label }}: {{ event.local }} ({{ event.utc }})
Distance breakdown
Kilometers
{{ distanceBreakdown.km }}
Miles
{{ distanceBreakdown.mi }}
Nautical miles
{{ distanceBreakdown.nm }}
Kaaba reference

Masjid al-Haram (Kaaba) coordinates anchor every calculation.

  • Latitude: 21.422487° N
  • Longitude: 39.826206° E
  • Longitude difference: {{ longitudeDifferenceDisplay }}
  • Solar noon offset: {{ solarOffsetDisplay }}
Metric Value Copy
{{ row.label }} {{ row.display }}

                    
:

Introduction:

Qibla direction is the bearing from your position to the Kaaba in Makkah, expressed clockwise from true north. It supports daily prayer and helps with practical room or outdoor orientation.

The calculation follows the shortest path on the Earth and reports both the bearing and the distance along the surface. You also see a central angle that shows how far around the globe the path spans.

Magnetic declination can be entered to turn the true bearing into a heading for a physical compass. Sun alignment times offer quick observational checks when daylight and a clear view are available.

Provide coordinates directly, search a city, select a point on a map, allow a GPS fix, or use an IP based estimate. Keep inputs consistent between attempts to make results comparable over time.

Technical Details:

Qibla direction measures the horizontal orientation from an observer to the Kaaba as a true bearing. Inputs are latitude and longitude in decimal degrees, treated as a momentary snapshot rather than an average over time.

The computation derives an initial bearing and a great‑circle distance. Bearings are described in degrees clockwise from true north and may be translated into a 16‑point cardinal label for readability.

Distance is computed from the central angle between the two points on a sphere. The distance equals that angle multiplied by a chosen Earth radius. A separate setting converts the true bearing to a magnetic heading using a user‑supplied declination where east is positive.

Results include bearing, cardinal label, distance in multiple units, central angle, and an optional magnetic heading. Comparisons assume identical coordinates, the same Earth radius choice, and the same declination.

θ = atan2 ( sin(Δλ)cos(φ2) , cos(φ1) sin(φ2) sin(φ1) cos(φ2) cos(Δλ) ) Δλ = λ2λ1
Symbols and units
Symbol Meaning Unit/Datatype Source
φ1Observer latitudedegreeInput
λ1Observer longitudedegreeInput
φ2Kaaba latitudedegreeConstant
λ2Kaaba longitudedegreeConstant
ΔλLongitude differencedegreeDerived
θInitial bearing from observerdegreeDerived
cCentral angleradian/degreeDerived
dGreat‑circle distancekm, mi, nmDerived
REarth radius (mean/equatorial/polar/custom)kmSetting
DMagnetic declination (east positive)degreeInput
OSolar noon offset vs MakkahhourDerived
Worked example. Observer at 40.7128° N, 74.006° W, mean radius R = 6371.0088 km, declination D = 0°. Using the formulas above:
θ 58.4817° (ENE) c 92.6869° d = Rc10306.322 km6404.052 mi5564.969 nm
Longitude difference is 113.83° west of Makkah; solar noon occurs about 7.59 h behind Makkah. A zero declination keeps magnetic and true headings equal.
a = sin2(Δφ2) + cos(φ1) cos(φ2) sin2(Δλ2) c = 2atan2(a,1a) d = Rc H = (θD+360)mod360 O = λ1λ215 hour

Units, precision, and rounding policy

  • Bearings display with 0 to 3 decimals as selected; distances show two decimals under 100 and whole numbers at 100 or more.
  • Latitude and longitude print to six decimals; sexagesimal format uses 0.1 s resolution with hemisphere letters.
  • Cardinal labels come from a 16‑point wind rose rounded to the nearest sector.

Validation & bounds

Input validation and limits
Field Type Min Max Step/Pattern Error handling
LatitudeNumber−90900.0001Clamped to range
LongitudeNumber−1801800.0001Normalized to [−180, 180]
Earth radius (custom)Number1000100001Clamped to range
Bearing precisionInteger031Rounded to nearest integer
Magnetic declinationNumber0.1Applied as east positive
City search queryText2 charsPlain textNetwork errors surfaced

Networking & storage behavior

  • IP based coordinates request a public geolocation record and apply the returned latitude and longitude.
  • City search sends queries to a public geocoding service and returns up to 10 matches with coordinates and context.
  • The map view retrieves raster tiles from a public tile server when visible.
  • All calculations run on the device; no app‑specific server stores your coordinates.

Assumptions & limitations

  • Earth is modeled as a sphere; ellipsoidal geodesics are not used.
  • Magnetic declination is not auto‑fetched and must be supplied by the user.
  • Sun alignment dates and times are fixed annually and ignore year‑to‑year astronomical variation.
  • Cardinal labels are an approximation for readability, not survey‑grade bearings.
  • Accuracy near the poles degrades and initial direction may be unstable.
  • Network lookups may be rate‑limited or blocked by local policy.
  • Map display depends on graphics support and network access for tiles.
  • Heads‑up Valid bearings do not prove access or visibility at the destination.

Edge cases & error sources

  • Coordinates exactly at the Kaaba make the bearing undefined.
  • Latitudes outside bounds are clamped; longitudes wrap to [−180, 180].
  • Declination sign errors flip the magnetic adjustment east versus west.
  • Blocked GPS permission prevents precise fixes on devices.
  • Offline use disables IP, city search, and map tiles.
  • Slow networks may time out external lookups.
  • Locale number formats may differ; numeric inputs expect digits and a decimal point.
  • Floating‑point rounding may shift values at high precision settings.
  • Time zone misconfiguration skews displayed sun alignment times.
  • Extremely short distances amplify rounding in DMS formatting.

Privacy & compliance

Location calculations run on the device. When you request IP lookup, city search, or map tiles, your device contacts external services directly; no additional personal data is collected by the app.

Step‑by‑Step Guide:

Compute a Qibla bearing and distance with clear, compass‑ready output.

  1. Select a location method and set Latitude and Longitude.
  2. Optionally allow a GPS fix or refresh the IP estimate.
  3. Open Advanced, pick an Earth model, or enter a custom radius.
  4. Enter magnetic declination if you need a compass heading. East is positive.
  5. Read the true bearing with its cardinal label and the distance.
  6. Use the sun alignment times as a periodic visual check when conditions allow.

Example. With 40.7128° N, 74.006° W and mean radius, the bearing is about 58.5° (ENE) and the distance is about 10306.32 km.

  • Save the numeric summary if you will compare locations later.

FAQ:

Is my data stored?

Calculations run on your device. IP lookup, city search, and map tiles contact external services. The app does not send your coordinates to its own server.

Your network or those services may log requests.
How accurate is the bearing?

It uses a spherical Earth model, which is suitable for everyday orientation. For survey work or critical navigation, use an ellipsoidal geodesic calculator.

What units and formats are shown?

Bearings in degrees with a 16‑point label, distances in kilometers, miles, and nautical miles, latitude and longitude in decimal and DMS formats.

Can I use it offline?

Yes for manual coordinates. IP detection, city search, and the map require a network connection to fetch data and tiles.

How do I find magnetic declination?

Consult a current source for your location and date, then enter the value. Positive values mean magnetic north is east of true north.

What does “central angle” mean?

It is the angular separation between the two points at Earth’s center. Larger angles indicate longer great‑circle paths.

Why do sun alignment times differ?

Times are fixed annual instants and your local display uses the device time zone. Weather, latitude, and obstructions affect visibility.

Does it cost anything?

No pricing information is included. The calculator runs on the device; external services may have their own usage policies.

Troubleshooting:

  • No GPS fix — grant location permission and try again.
  • Map does not load — check your connection and reload the page.
  • City search returns nothing — try alternate spellings or a nearby city.
  • IP estimate is off — switch to GPS, map, or manual coordinates.
  • Compass feels wrong — verify declination sign and value.
  • Numbers look odd — ensure decimal points are used for inputs.

Advanced Tips:

  • Tip Keep the same Earth radius choice when comparing different places.
  • Tip Record declination alongside bearings to preserve reproducibility.
  • Tip Use the central angle to sanity‑check very long distances.
  • Tip Prefer GPS for field use; then fine‑tune with map or manual entry.
  • Tip Note weather and obstacles when using sun alignment as a check.
  • Tip For very short distances, rely on cardinal labels rather than decimals.

Glossary:

Qibla
Direction from a place to the Kaaba in Makkah.
True bearing
Angle clockwise from true north.
Magnetic declination
Angle between magnetic and true north.
Great‑circle
Shortest path on a sphere’s surface.
Central angle
Angle between points measured at Earth’s center.
Cardinal label
Compass sector name like ENE or SW.