好吧,我正在 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/