1

我正在使用Google Maps以显示当前用户位置。虽然使用北部总是在顶部,但我的问题是:可以根据用户方向改变它吗?例如,如果用户转向南方,那么南方应该在顶部。
我怎样才能做到这一点?

我的应用程序 minimun sdk 版本是 2.2

4

2 回答 2

2

您可以处理传感器事件(这可以为您提供用户的方位),然后您必须使用动画旋转 MapView。

您可以使用 location.getBearing(); 以得到用户的承担。然后,您可以旋转视图

// 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);
于 2012-06-27T14:05:53.183 回答
1

我建议使用mapView.setRotation(bearing). 这就是我使用的(我有一个类似于你的应用程序)。我不确定引入了什么 API 级别,但它适用于我(2.3.4)。确保您mapView.invalidate()在旋转地图后致电。

于 2012-06-27T19:37:31.400 回答