【发布时间】:2021-08-17 09:37:55
【问题描述】:
我正在使用 Yandex MapKit。我可以绘制路线(折线),但我怎样才能像这样为它制作动画? - https://yandex.ru/dev/maps/jsbox/2.1/polyline_animation
【问题讨论】:
标签: android yandex-maps yandex-mapkit
我正在使用 Yandex MapKit。我可以绘制路线(折线),但我怎样才能像这样为它制作动画? - https://yandex.ru/dev/maps/jsbox/2.1/polyline_animation
【问题讨论】:
标签: android yandex-maps yandex-mapkit
我尝试通过 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()
}
【讨论】: