Android MapView MapController stopAnimation 不停止动画

标签 android android-mapview

好吧,我正在 Android 中开发一个地理定位应用程序。第一次运行时,我们将 map 以当前位置为中心,然后用户可以自由缩放和平移,但我们有一个按钮可以使 map 动画化并使其回到实际位置。

问题是,本地图是静态的时候,这只会发生:如果用户滚动 map 并让它因惯性滚动,这个按钮将在动画停止之前不起作用。

这是代码。

mapView.getController().stopAnimation(false); //this aint working as expected
mapView.getController().animateTo(myLocationOverlay.getMyLocation());

谢谢。

最佳答案

这对我有用:

public void centerCurrentClickHandler(View v) {
    if (hasCurrentPosition) {
        GeoPoint point = new GeoPoint(currentLatitudeE6, currentLongitudeE6);
        mapController.animateTo(point);
    }
}

public void centerFlagClickHandler(View v) {
    if (hasPushpinPosition) {
        GeoPoint point = new GeoPoint(pushpinLatitudeE6, pushpinLongitudeE6);
        mapController.animateTo(point);
    }
}

关于Android MapView MapController stopAnimation 不停止动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11622340/

相关文章:

android - 如何使用 viewpager 在选项卡布局中添加 map ?

google-maps - 在非 Activity 类中使用 TextView 资源。 MainActivity 停止并显示 "Exception despatching input event."

android map 项目未清除

android - Robotium 是否可以可靠地测试 Activity 和 fragment 的启动速度?

android - 带有包含 MapView 的 Fragment 的 FragmentActivity

android - 在谷歌地图上画一条线/路径

Android Mail 应用不断调整内容大小

java - 以编程方式将规则添加到布局中已有的 View - Android

android - 仅在 Debug模式下使用特定的 minSdkVersion

java - Android EditText 值在按钮单击时不会更改