I\'m writing an application on android that will show a map from google maps. When I start the app, the map is centered on the current location. When I use animateCamera
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()));
}
});