Hi,
I am trying to make a religious compass pointing to holy places
But as you can see in the attached it is not working properly
My app (with white background) is pointing to a wrong direction where the other photo shows another published app showing the correct location
Also, how can I make the accuracy up to 90 degree only because it won't be correct if it exceeded 90 degree?
Sample app and the screenshots are attached
Thanks,
Jassim
Answers
I think that you should specify your question in more details. You should say what isn't working. Map isn't working because you tried this code etc. your question is like my app isn't working please fix it for me. Nobody has time for it to debug and program for you.
@batmaci I already mentioned the problem it's pointingg ot a wrong direction
This is what I am getting:
and this is where it should point:
Here is the update sample app attached
1.Try to use Xamarin.Essentials.Compass to monitor the device's magnetic north heading.
Tutorial:
https://docs.microsoft.com/en-us/xamarin/essentials/compass?tabs=android
2.A sample about compass application:
https://github.com/jamesmontemagno/app-compass
but Essentials' Compass does not provide property to set a custom heading point?
It's just mathematics/trigonometry and nothing related to Xamarin.Forms. You have Makkah GPS coordinates, just find the current GPS position of the user (Essentials.Geolocation), current compass heading (Essentials.Compass) and then you calculate the right Qibla angle and rotate your image accordingly.
I tried that but it's going to wrong direction as you can see in the attached sample
Why are you using Accelerometer?
because the Essentials Compass doesn't have the option to set custom location and only point heading to current location
You need to do 3 things:
Also you don't need Accelerometer, you're not moving, but rotating.
I hate Math
I tried this but still not pointing to the correct Qibla (also attached)
You're not applying the formula I gave you, you are overcomplicating things (calculating directions, converting to rad/degs, normalizations you don't need...) by pasting code you don't understand from I don't know where. Just create a blank new project, forget everything you did, and do what I showed you, you'll finish in 10 minutes or less. Also you don't need to calculate the Qibla angle each time the Compass turns, as the Qiblah is relative to a position, not your current direction, calculate it only once after you receive the GPS position (or the GPS position is updated). The compass is just to show the user her/his direction relative to the Qibla (and the North)
Thanks Amaar
I tried attached for the same location (Bakersfield) but getting different figures
One more question please, where the Essentials' Compass role comes here?
Sorry, it's first time I try Compass and such Math
How about the last two steps in the image, I mean (Makkah Angle relative to North from current position) and (East from True North)?
Thanks in advance
I am getting the correct degree now but my problem is how to adjust the pointer with the compass current heading
My pointer is accepting double value like this:
pointer1.Value = bearing_degree;
because I am getting the correct direction but not when I move the device