@Override public float getRotation() { if (virtual != null) { return virtual.getRotation(); } return 0.0f; }
public void animateMarker(final Marker marker, final Location location) { final Handler handler = new Handler(); final long start = SystemClock.uptimeMillis(); final LatLng startLatLng = marker.getPosition(); final double startRotation = marker.getRotation(); final long duration = 500; final Interpolator interpolator = new LinearInterpolator(); handler.post( new Runnable() { @Override public void run() { long elapsed = SystemClock.uptimeMillis() - start; float t = interpolator.getInterpolation((float) elapsed / duration); double lng = t * location.getLongitude() + (1 - t) * startLatLng.longitude; double lat = t * location.getLatitude() + (1 - t) * startLatLng.latitude; float rotation = (float) (t * location.getBearing() + (1 - t) * startRotation); marker.setPosition(new LatLng(lat, lng)); marker.setRotation(rotation); if (t < 1.0) { // Post again 16ms later. handler.postDelayed(this, 16); } } }); }