Find Your Way to a Destination
If we are heading toward a destination and want to use our Android device like a compass to guide us there, we need to calculate the angle toward the destination relative to our location. And to make it at all useful, we also need to consider the direction the device is “looking” relative to geographic north. When used together, these two numbers can then successfully point us to where we want to go. We’ll build on the code, and add a simple triangle to our user interface that points toward our destination no matter which way the device itself is facing.
The core idea here is that we’ll calculate the bearing and then use it to rotate a graphic object, a triangle, which will serve as our compass needle. The ...
Get Rapid Android Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.