Android如何在MapController中停止animateTo

时间:2012-11-26 18:51:51

标签: android android-mapview android-maps

为了动画到地图上的某个点我使用

  

myMapController.animateTo(点);

但有时我必须运行另一个动画指向。为了不让一些元素闪烁,我需要停止上一个动画。

我试过这两个:

  

myMapController.stopPanning()

     

myMapController.stopAnimation(假);

但它没有帮助

有什么想法吗?

谢谢!

1 个答案:

答案 0 :(得分:0)

要停止动画,您需要使用参数true(而不是问题中的false)调用下面的方法:

myMapController.stopAnimation(true);

这会停止动画并立即将地图移动到animateTo()请求的最终位置。

如果要停止动画并将地图保持在原位(在动画的中间位置),请使用以下内容:

    GeoPoint movingCenter = mapView.getProjection().fromPixels(mapView.getWidth()/2, mapView.getHeight()/2);
    myMapController.stopAnimation(true);
    myMapController.setCenter(movingCenter);

问候。