【问题标题】:How to animate polyline in Yandex mapkit如何在 Yandex mapkit 中为折线设置动画
【发布时间】:2021-08-17 09:37:55
【问题描述】:

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

【问题讨论】:

    标签: android yandex-maps yandex-mapkit


    【解决方案1】:

    我尝试通过 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()
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-19
      • 2020-12-08
      • 2018-08-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多