Example:
//Get the current location
Location startingLocation = new Location("starting point");
startingLocation.setLatitude(myMap.getCameraPosition().target.latitude);
startingLocation.setLongitude(myMap.getCameraPosition().target.longitude);
//Get the target location
Location endingLocation = new Location("ending point");
endingLocation.setLatitude(<target>.latitude);
endingLocation.setLongitude(<target>.longitude);
//Find the Bearing from current location to next location
float targetBearing = startingLocation.bearingTo(endingLocation);
Thank you, this is very useful :-)
ReplyDeleteWould you please (in another article) give an example of using this data to display an arrow pointing to the correct direction ?
I guess this should use the compass data as well and compare them ?
Thank you for your great blog, it is always a pleasure to read your very useful articles :-)