Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

Point to exact place using latitude and longitude in compass

Open jrahma opened this issue 7 years ago • 9 comments

Hi,

Please add an option compass to point o exact latitude and longitude in compass..

This will be very helpful for pointing to locations such as holy places and guide in dessert to way out, etc..

Thanks, Jassim

jrahma avatar Mar 09 '19 13:03 jrahma

Do you have an example of what you are trying to do? I think you are just looking to calculate how to point an arrow based off the current compass and point an arrow.

jamesmontemagno avatar Mar 11 '19 15:03 jamesmontemagno

This is what I am trying to do:

https://en.m.wikipedia.org/wiki/Qibla_compass

jrahma avatar Mar 11 '19 15:03 jrahma

@jrahma You seem to want to calculate the compass bearing, which can be used along side the Compass API that're already provided by Xamain.Essentials

Δφ = ln( tan( latB / 2 + π / 4 ) / tan( latA / 2 + π / 4) ) Δlon = abs( lonA - lonB ) bearing : θ = atan2( Δlon , Δφ ) Note: 1) ln = natural log 2) if Δlon > 180° then Δlon = Δlon (mod 180). 3) operation a mod n 4) function atan2(y, x) 5) the angles are in radians

taken from: https://www.sunearthtools.com/tools/distance.php

itsmuntadhar avatar Apr 01 '19 14:04 itsmuntadhar

@sparkist97 sorry I didn't get

For example, I want Essentials' Compass to always point to this location:

21.4225° N, 39.8262° E

so how to do this using Xamarin Essential?

jrahma avatar Jun 10 '19 19:06 jrahma

This is not a supported feature currently and this is something you would pragmatically need to implement.

With Xamarin.Essentials you could get the current compass reading, you are just really trying to figure out how to take and and combine it with math based on lat/long like @sparkist97 mentioned.

jamesmontemagno avatar Jun 13 '19 20:06 jamesmontemagno

Thanks James but hope this will added as feature request

jrahma avatar Jun 13 '19 21:06 jrahma

I think that you would use something such as this: https://stackoverflow.com/questions/2042599/direction-between-2-latitude-longitude-points-in-c-sharp or https://stackoverflow.com/questions/7173925/how-to-rotate-a-direction-arrow-to-particular-location

You have all the pieces you need and it is just math and UI from there on. We could do something in a helper, but all of the math and conversions are already there.

jamesmontemagno avatar Jun 13 '19 23:06 jamesmontemagno

What is the property to use in Essential's Compass to set the pointer?

jrahma avatar Aug 11 '19 09:08 jrahma

This seems like a UI implementation as part of an app, which would calculate the bearing in relation to the current device position and the display that relative to the compass reading

davehump avatar May 28 '20 20:05 davehump