0

我正在使用 Yandex MapKit。我可以绘制路线(折线),但我怎样才能像这样为它制作动画?- https://yandex.ru/dev/maps/jsbox/2.1/polyline_animation

4

1 回答 1

0

我试图通过 ValueAnimator 来做到这一点。它适用于我的任务

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()
}
于 2022-01-13T10:35:17.183 回答