Is it possible to have compass-like app point to a specific location?

I want to be able to have compass like the sample compass app, except I want to set longitude + latitude, and have it point there.

In sample, there’s this code:

Runtime:addEventListener( “heading”, updateCompass )

which sets event.geographic, that seems to work as a compas, but I’d like it to point to specific longitude/latitude instead. Is that possible?

If not, any other ideas how to make such an app?

I’m not sure you need the compass for this as much as just GPU data and a little trig.   Using your Lat, Long and the Lat, Long of your target.  You now have two points on a right triangle.  You can calculate the distance of the base and height of a right triangle and then get the angle and then be able to draw your pointer.

Rob

Rob, thanks for your comment.

But lets say for example that my current position is (1,1), and I want to head to (2,2). I believe that’s 45 degree angle, but to be able to draw an arrow pointing at the right direction, I need to know where my phone is pointing.

Basically if I stand at point (1,1) and spin in a circle, the arrow should rotate to maintain it’s direction pointing at the (2,2) location - kind of like compass always points to actual north, not at just 90 degree angle.

So I beleive if I do all the math myself, I’d have to know where the phone is pointing to first, and add the calculation of right angle to it.

Maybe I misunderstood your answer though.

ok, well I’ll think about it after new year.

Happy New Year

I guess you would need the compass information to know the direction you’re pointing. 

I’m not sure you need the compass for this as much as just GPU data and a little trig.   Using your Lat, Long and the Lat, Long of your target.  You now have two points on a right triangle.  You can calculate the distance of the base and height of a right triangle and then get the angle and then be able to draw your pointer.

Rob

Rob, thanks for your comment.

But lets say for example that my current position is (1,1), and I want to head to (2,2). I believe that’s 45 degree angle, but to be able to draw an arrow pointing at the right direction, I need to know where my phone is pointing.

Basically if I stand at point (1,1) and spin in a circle, the arrow should rotate to maintain it’s direction pointing at the (2,2) location - kind of like compass always points to actual north, not at just 90 degree angle.

So I beleive if I do all the math myself, I’d have to know where the phone is pointing to first, and add the calculation of right angle to it.

Maybe I misunderstood your answer though.

ok, well I’ll think about it after new year.

Happy New Year

I guess you would need the compass information to know the direction you’re pointing.