动画相机不断导致地图承载不平滑

时间:2017-02-20 09:47:07

标签: android google-maps animation google-maps-android-api-2

我想通过MapView更改后的价值来轮播sensor。但它并不像Google Maps申请那么顺利。似乎连续调用的animate方法导致maps轴承不平滑。似乎新animateCamera来电会取消之前的animation来电,不是吗?我在下面的代码中做错了什么?我可以提高轴承性能吗?

    mSensorManager.setOnDeviceRotationListener(bearing -> {
                if (mCurrentLocation == null 
                     || Math.abs(mOldBearing - bearing) < ROTATION_THRESHOLD) { // atleast 5 degrees.
                    return;
                }
                mOldBearing = bearing;
                LatLng target =
                        new LatLng(mCurrentLocation.getLatitude(), mCurrentLocation.getLongitude());
                CameraPosition oldCamera = mGoogleMap.getCameraPosition();
                CameraPosition newCamera = CameraPosition.builder()
                        .zoom(Math.max(oldCamera.zoom, DEFAULT_MAP_COMPASS_ZOOM))
                        .target(target)
                        .tilt(DEFAULT_MAP_TILT)
                        .bearing(bearing)
                        .build();
                mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(newCamera));
            }

0 个答案:

没有答案