Android的谷歌地图V2摄像头动画 [英] Android Google Maps v2 Camera Animation
问题描述
所以林不知道这是否是一个错误或没有......可能还是我可能已经错过了一些东西。
So im not sure if this is a bug or not yet... might be or I may have missed something.
反正所以这里是链接到谷歌地图V2相机控制。的https://developers.google.com/maps/documentation/android/views#moving_the_camera
Anyway so here is the link to Google Maps V2 Camera Controls. https://developers.google.com/maps/documentation/android/views#moving_the_camera
这个问题:
动画已经到动画不调用onFinish(位置);
Animate to a location already animated to does not call onFinish();
如何复制:
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(mLocation.getLatLng(), zoomLevel), 200, new GoogleMap.CancelableCallback() {
@Override
public void onFinish() {
//DO some stuff here!
Log.d("animation", "onFinishCalled");
}
@Override
public void onCancel() {
Log.d("animation", "onCancel");
}
});
这问题可能来约当用户双击水龙头的东西,要求即使之间有一个很长一段时间同样的动画,onFinish将只能被称为一个成功的动画。当相机已经定位的onFinish方法不会被调用!
This issue may well come about when a user double taps something which called the same animation even if there is a long time between, onFinish will only be called for a successful animation. When the camera is already positioned the onFinish method will not be called!
我就可以去各地做检查之前,我做任何相机的动画,但我不喜欢,作为它的一种浪费。
I could go around doing checks before I do any camera animation but I don't like that as its wasteful.
任何帮助将是AP preciated。 谢谢你。
Any help would be appreciated. Thanks.
推荐答案
我有同样的问题时,我想移动摄像机到同一位置,这似乎是一个错误。 即使旧的和新的位置是不一样的,差异是如此之小,例如:老position.latitude = 94.54284009112,新position.latitude = 94.54284003451,忽略了最低的工作。 我的解决办法是截断值只得到old_position.latitude = new_position.latitude = 94.54,然后我做了测试。
I have the same problem when i want to move camera to the same position, it seems like a bug. Even if old and new position are not the same and the difference is so small , ex: old position.latitude = 94.54284009112, new position.latitude = 94.54284003451, it dosen't work. my solution is to truncate values to get only old_position.latitude = new_position.latitude = 94.54, then i do a test.
还有一个问题是与移动摄像机和滚动地图的同时,对于我禁用滚动手势移动前及onFinish(启用它)和OnCancel的()。
There is another problem with moving camera and scroll the map in the same time, for that i disable scroll gesture before moving and enable it on the onFinish() and the onCancel().
public void animateCameraTo(final double lat, final double lng)
{
_googleMap = getMap();
CameraPosition camPosition = _googleMap.getCameraPosition();
if (!((Math.floor(camPosition.target.latitude * 100) / 100) == (Math.floor(lat * 100) / 100) && (Math.floor(camPosition.target.longitude * 100) / 100) == (Math.floor(lng * 100) / 100)))
{
_googleMap.getUiSettings().setScrollGesturesEnabled(false);
_googleMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(lat, lng)), new CancelableCallback()
{
@Override
public void onFinish()
{
_googleMap.getUiSettings().setScrollGesturesEnabled(true);
}
@Override
public void onCancel()
{
_googleMap.getUiSettings().setAllGesturesEnabled(true);
}
});
}
}
希望这有助于你;)
Hope this helps you ;)
这篇关于Android的谷歌地图V2摄像头动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!