Retrieving the bearing between two locations

The net.rim.device.api.gps.LocationInfo class provides a method that allows you to retrieve the bearing between two locations. The LocationInfo.getBearing method receives the coordinates for a start location and an end location of a course as parameters, and returns the bearing. The bearing is an angle (in degrees) between a line connecting two points (the origin and the destination) and a north-south line. For example, if the end location is directly northeast of the start location, the bearing is 45 degrees.

double bearing = LocationInfo.getBearing(lat1, lon1, lat2, lon2);

Was this information helpful? Send us your comments.