No way to get, or calculate, magnetic declination using xamarin essentials?

Louis Elston 21 Reputation points
2021-10-05T15:05:13.673+00:00

Essentials Compass- gets me true north. Essentials Magnetometer gets me X, Y, Z. Is X,Y,Z, the magnetic declination, if so, how to use it\convert it (is x the declination?)? You can go to https://www.ngdc.noaa.gov/geomag/calculators/mobileDeclination.shtml (on PC, it says that you should be using mobile device), and it shows me the declination where I am located. Not sure how to get this app on my Android phone (S21+), but anyway, really don't want to have to access online app to get this information to use in my own app. Is there no way of getting this information in Xamarin forms? Thanks.

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
{count} votes

Accepted answer
  1. Kyle Wang 5,531 Reputation points
    2021-10-06T07:28:15.693+00:00

    Hi LouisElston-4087,

    Welcome to our Microsoft Q&A platform!

    Xamarin provides full access to the underlying platform, so you can get the declination at a specific point by directly calling the Android GeomagneticField API which provides method "getDeclination" to get declination.

    Here is the documentation you can refer to: GeomagneticField. You can also find the .Net documentation for this at GeomagneticField.Declination

    There is a feature request to add this to Xamarin.Essentials at Feature Request True north heading in Compass. You can like it or add comments with your use case to help prioritize it.

    Regards,
    Kyle


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Justin 1 Reputation point
    2023-03-27T20:05:53.7633333+00:00

    If you want a more self contained approach that doesn’t rely on external communication or device native libraries, you can use CoordinateSharp.

    https://coordinatesharp.com/DeveloperGuide#magnetic-fields

    0 comments No comments