Can anyone tell me what I could use to accomplish this? I had trouble determining where the phone is facing and how to rotate the camera view of the map the reflect the change in where the phone is facing.
Asked
Active
Viewed 1,779 times
1 Answers
0
Use SensorManager.getOrientation(float[] R, float[] values)
to get the compass direction of the phone. You'll have to read into the documentation for getOrientation()
, it is a little complicated, I'll leave that exploration to you :)
Once, you have the heading (direction) of the phone, you can use a function like the following to rotate your map (taken from here):
public void updateCamera(float bearing) {
CameraPosition currentPlace = new CameraPosition.Builder()
.target(new LatLng(centerLatitude, centerLongitude))
.bearing(bearing).tilt(65.5f).zoom(18f).build();
googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(currentPlace));
}
Let me know if you have any other questions!