# Compass & Qibla Finder

**URL:** <https://community.thunkable.com/t/compass-qibla-finder/4107674>\
**Category:** Questions about Thunkable X\
**Tags:** canvas, help\
**Created:** [September 27, 2025, 9:46am UTC](https://community.thunkable.com/t/compass-qibla-finder/4107674 "2025-09-27T09:46:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![doctorsof](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/doctorsof/32/30099_2.png) [@doctorsof](https://community.thunkable.com/u/doctorsof)\
**Post date:** [September 27, 2025, 9:46am UTC](https://community.thunkable.com/t/compass-qibla-finder/4107674/1 "2025-09-27T09:46:11Z")

</div>

Users will be able to use a compass with the Kaaba marked on one side, allowing them to both use the compass and see the direction of the Kaaba. I asked artificial intelligence how to do this, and it gave me a bunch of formulas to calculate. Is it really that difficult to calculate or is there a simpler way to do this within Thunkable? I need to understand the logic behind this topic; artificial intelligence couldn’t help me understand it. (Kaaba Lat: 21.42253659824817 Long: 39.82620321214199) I did with polyline but didn’t on compass.

 ![44](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/1/e/1e2294917256e4ea5cb39971109aad252f7145fb.png)

 ![33](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/b/5ba8d18ed1f4aa256f895103b386df6980163b82.png)

 ![22](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/7/67de4d08f4e9592176d4ddbd7013f43fb7527bee.png)

Thank you.

> ### Qibla Compass Bearing Formula (Shortest Version)
> 
> To calculate the Qibla direction (bearing) from any location to the Kaaba:
> 
> #### 1. Convert degrees to radians
> 
> ```auto
> φ1 = userLatitude * PI / 180
> λ1 = userLongitude * PI / 180
> φ2 = 21.4225 * PI / 180 // Kaaba latitude
> λ2 = 39.8262 * PI / 180 // Kaaba longitude
> 
> ```
> 
> #### 2. Delta longitude
> 
> ```auto
> Δλ = λ2 - λ1
> 
> ```
> 
> #### 3. Bearing formula
> 
> ```auto
> bearing_deg = ( atan2( sin(Δλ) * cos(φ2),
> cos(φ1) * sin(φ2) - sin(φ1) * cos(φ2) * cos(Δλ) )
> * 180 / PI + 360 ) mod 360
> 
> ```
> 
> - `atan2(y, x)` in Thunkable takes two inputs.
> 
> This gives you the **bearing** from the user’s current location to the Kaaba, in degrees from North (0 = North, 90 = East, 180 = South, 270 = West).
> 
> #### 4. Relative angle with device heading
> 
> Use Thunkable’s Magnetometer Heading (0–360° relative to North):
> 
> ```auto
> relativeAngle = (bearing_deg - deviceHeading + 360) mod 360
> 
> ```
> 
> You can then rotate your arrow or Kaaba sprite by `relativeAngle`.

---

<div class="post-metadata">

**Author:** ![ozel1978](https://avatars.discourse-cdn.com/v4/letter/o/3ec8ea/32.png) [@ozel1978](https://community.thunkable.com/u/ozel1978)\
**Post date:** [September 28, 2025, 3:27pm UTC](https://community.thunkable.com/t/compass-qibla-finder/4107674/2 "2025-09-28T15:27:36Z")

</div>

so your block working fine right now?

---

<div class="post-metadata">

**Author:** ![doctorsof](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/doctorsof/32/30099_2.png) [@doctorsof](https://community.thunkable.com/u/doctorsof)\
**Post date:** [September 28, 2025, 4:45pm UTC](https://community.thunkable.com/t/compass-qibla-finder/4107674/3 "2025-09-28T16:45:34Z")

</div>

Not yet, I’m still trying to fix everything.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [December 27, 2025, 4:46pm UTC](https://community.thunkable.com/t/compass-qibla-finder/4107674/4 "2025-12-27T16:46:02Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
