GoogleMap won't load detailed map until user interaction

纵饮孤独 提交于 2019-12-02 07:49:59

Found solution :

animateCamera MUST be called from the main looper. The LocationListener is called from another thread (sensor's thread).

So the code become :

final float zoom = 19.0f;

final LatLng target = new LatLng(location.getLatitude(), location.getLongitude());

// tilting camera depending on speed
final float tilt = Math.min(90, location.getSpeed()*10);

m_handler.post(new Runnable() {
    public void run() {
        // moving car marker
        m_locationMarkerG.setPosition(target);
        m_locationMarkerG.setRotation(location.getBearing());

        // moving camera
        m_mapViewG.animateCamera(CameraUpdateFactory.newCameraPosition(CameraPosition.builder().zoom(zoom).bearing(location.getBearing()).target(target).tilt(tilt).build()));
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!