【发布时间】:2019-12-16 07:43:23
【问题描述】:
我正在 android 上编写一个应用程序,它将显示来自谷歌地图的地图。当我启动应用程序时,地图以当前位置为中心。当我使用animateCamera时,我可以看到整个世界的放大动画,直到它聚焦于当前位置。
问题是我需要触摸地图才能让地图以我预期的缩放级别显示。
这是我在触摸屏幕之前得到的: Before touch
这是我触摸屏幕后得到的: After touch
如果我触摸屏幕,图像将保持正常,直到我行驶了几百米,然后它再次无法使用。有时会出现图像,但每 10 公里只有 1 到 2 次。
这是我在LocationListener::onLocationChanged 中移动相机的方法:
float zoom = 19.0f;
LatLng target = new LatLng(location.getLatitude(), location.getLongitude());
// moving car marker
m_locationMarkerG.setPosition(target);
m_locationMarkerG.setRotation(location.getBearing());
// tilting camera depending on speed
float tilt = Math.min(90, location.getSpeed()*10);
m_mapViewG.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder().zoom(zoom).bearing(location.getBearing()).
target(target).tilt(tilt).build()));
我可以尝试什么来解决这个问题?
谢谢
【问题讨论】:
-
使用前是否调用m_mapViewG.onCreate()?
-
不,com.google.android.gms.maps.GoogleMap 上没有这种方法
标签: android google-maps android-maps-v2