[Android Google Maps在使用GoogleMap.AnimateCamera()时未加载地图

问题描述 投票:0回答:1

Google Maps文档

根据Google maps document,为了将CameraUpdate应用于地图,我们可以立即移动相机(通过使用GoogleMap.moveCamera(CameraUpdate))或平滑地为相机设置动画(通过使用GoogleMap.animateCamera(CameraUpdate))。

我做了什么

所以我首先使用GoogleMap.moveCamera(CameraUpdate)。可以很好地加载地图。但是,当我使用GoogleMap.animateCamera(CameraUpdate)时,无法加载地图。我看到的只是一个灰色的屏幕或模糊的地图。除非我手动移动地图,否则地图将完全加载或变得清晰。

有人可以告诉我这是什么问题吗?使用GoogleMap.animateCamera()时是否需要其他功能?

   val cameraPosition = CameraPosition.builder(mMap.cameraPosition)
                                    .target(myLatLng)
                                    .bearing(myBearing)
                                    .tilt(50f)
                                    .build()
    val cameraUpdate = CameraUpdateFactory.newCameraPosition(cameraPosition)
    // the map will be loaded just fine with this method
    // mMap.moveCamera(cameraUpdate)

    // the problem appeared when I update camera with aniteCamera()
    mMap.animateCamera(cameraUpdate, 500, null)

android google-maps-android-api-2
1个回答
0
投票
    尝试将.builder(mMap.cameraPosition)...更改为.builder()...
  1. 请确保在onMapReady回调后调用此方法
© www.soinside.com 2019 - 2024. All rights reserved.