compass-geolocation

Calculate compass bearing / heading to location in Android

老子叫甜甜 提交于 2019-11-25 23:57:04
I want to display an arrow at my location on a google map view that displays my direction relative to a destination location (instead of north). a) I have calculated north using the sensor values from the magnetometer and accelerometer. I know this is correct because it lines up with the compass used on the Google Map view. b) I have calculated the initial bearing from my location to the destination location by using myLocation.bearingTo(destLocation); I'm missing the last step; from these two values (a & b) what formula do I use to get the direction in which the phone is pointing relative to