I know this is an old question, but ...
For this task, you can use the value interpolator:
fun changePositionSmoothly(marker:Marker?, newLatLng: LatLng){ if(marker == null){ return; } val animation = ValueAnimator.ofFloat(0f, 100f) var previousStep = 0f val deltaLatitude = newLatLng.latitude - marker.position.latitude val deltaLongitude = newLatLng.longitude - marker.position.longitude animation.setDuration(1500) animation.addUpdateListener { updatedAnimation -> val deltaStep = updatedAnimation.getAnimatedValue() as Float - previousStep previousStep = updatedAnimation.getAnimatedValue() as Float marker.position = LatLng(marker.position.latitude + deltaLatitude * deltaStep * 1/100, marker.position.longitude + deltaStep * deltaLongitude * 1/100) } animation.start() }
To prevent the accumulation of errors, at the end of the animation you can set a new position, but this is enough for most cases.
source share