Android MapView MapController stopAnimation not stopping animation

馋奶兔 提交于 2019-12-11 02:25:07

问题


well, i'm developing a geolocation app in Android. On first run we center the map at the current location, then the user can zoom and pan freedomly, but we have a button that animates the map and centers it back to the actual position.

The problem is that this just happens when the map is static: if the user scrolls the map and leaves it scrolling by inertia, this button won't work until the animation is stopped.

Here's the code.

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

Thanks.


回答1:


This works for me:

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);
    }
}


来源:https://stackoverflow.com/questions/11622340/android-mapview-mapcontroller-stopanimation-not-stopping-animation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!