How to animate polyline in Yandex mapkit

777 Views Asked by At

I am using Yandex MapKit. I can draw routes(polylines) but how can I animate it like this? - https://yandex.ru/dev/maps/jsbox/2.1/polyline_animation

1

There are 1 best solutions below

0
On BEST ANSWER

i tried to do it through ValueAnimator. It worked for my task

private fun displayRoute(pointsList: List<Point>) {
    val valueAnimator = ValueAnimator.ofInt(1, pointsList.size)
    valueAnimator.duration = 1200
    valueAnimator.addUpdateListener {
        val polylineMapObject = binding?.mapViewOrderDetail?.map?.mapObjects?.addPolyline(
            Polyline(pointsList.subList(0, it.animatedValue as Int))
        )
        polylineMapObject?.strokeColor = ContextCompat.getColor(requireActivity(), R.color.color_black)
    }
    valueAnimator.start()
}