I have try much but can not make Qibla compass for my application. I can't understand what I do. I need Qibla compass that works perfectly.
Just go to the address g.co/QiblaFinder on your smartphone and move the camera until the Kaaba symbol shows up, floating in space.
Because each region does not have the same degree of orientation, the HMC 5883L sensor should be operated by including GPS as a point of coordinate, so that the sensor can work by directly reading the angle of the direction of the Qibla.
Once the application is open, type Kaaba in the search box. Next the screen will display the results of the location of the Kaaba. Zoom out until you can point from your location and the Kaaba can fit in one screen. Point the top of the phone until the points on the screen face the Kaaba.
You know the location of Mecca and you know the users current location (if you have GPS or some other location provider). The bearing is given by this formula, latitudes and longitudes should be in radians.
float lonDelta = (lon2 - lon1);
float y = Math.sin(lonDelta) * Math.cos(lat2);
float x = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lonDelta);
float brng = Math.atan2(y, x).toDeg();
brng
is the direction in degrees.
You could also explore the Location.bearingTo() method, see here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With