简体   繁体   中英

How can I refresh google map programmatically after using animateCamera()?

        newPosition = new CameraPosition(new LatLng(latitude, longitude), zoomLevel, tilt, currentBearing);

        CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(newPosition);

        googleMap.animateCamera(cameraUpdate);

When I zoom in or move the camera to another point using animateCamera(), it takes a long time for it to refresh the map (it looks blurry). But if I tap the screen or slightly move the camera manually after animation ends, it immediately refreshes.

it looks like this after moving the camera

I want it to refresh and look like this after animation

I searched it in google maps documents but I didn't find a method for refreshing the map. Is there a way to refresh it programmatically?

I fixed this by calling moveCamera() when the animation ends. I am moving the camera to the same location just to make google maps load the map immediately. Couldn't find a better way.

CameraPosition newPosition = newCameraPosition(newLatLng(latitude,longitude), zoomLevel, tilt, currentBearing);

CameraUpdate cameraUpdate = CameraUpdateFactory.newCameraPosition(newPosition);

googleMap.animateCamera(cameraUpdate, new GoogleMap.CancelableCallback() {
    @Override public void onCancel() {}

    @Override
    public void onFinish() {
        googleMap.moveCamera(cameraUpdate);
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM