Using the computeHeading() function against my currentPosition and a destinationPosition i can get the angle returned (tis currently between -180 and +180).
heading = google.maps.geometry.spherical.computeHeading(
currentLocation,
destinationLocation
);
I can get the direction of the compass also using a function to return the alpha which gives me angle of rotation from north.
alpha = null;
//Check for iOS property
if (event.webkitCompassHeading) {
//window.confirm("iOS device - using webKit instead"); // report back that we are indeed on iOS
alpha = event.webkitCompassHeading;
}
//non iOS
else {
alpha = event.alpha;
}
var locationIcon = myLocationMarker.get('icon');
locationIcon.rotation = 360 - alpha;
myLocationMarker.set('icon', locationIcon);
This gives me the angle and then helps me rotate my icon so i can see if im pointing the correct way
Can someone tell me the math/js code to then get the way i'm facing against the destination to give me a returned result. I need to know if i'm facing the destination and then i can see if im facing the wrong way etc.
Im going to try to use some panning of web audio to help direct people to point the right way.
Thank you
edit: here is an image to maybe help clarify. Im sure its a simple calculation but i cant figure it out
I think it is just math, since..
then I guess you can figure out the rest?
note that since heading can change radically due to the GPS accuracy problem. Consider using both compass data and some kind of algorithms to ease the outliners.