我正在使用 Google map
来显示当前用户位置。虽然使用北方总是在最上面,但我的问题是:是否可以根据用户方向更改它?例如,如果用户转向南方,那么南方应该在顶部。
我该怎么做?
我的应用最低sdk版本是2.2
最佳答案
您可以处理传感器事件(它可以为您提供用户方位),然后您必须使用动画旋转您的 MapView。
您可以使用 location.getBearing();才能有用户的风度。 然后,您可以旋转 View
// Create an animation instance
Animation an = new RotateAnimation(from, to, pivotX, pivotY);
// Set the animation's parameters
an.setDuration(duration);
an.setFillAfter(true);
// Aply animation to view
mapView.setAnimation(an);
关于android - 如何根据用户方向显示谷歌地图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11227703/