问题描述
我目前正在开发一个 Android
应用程序来订购出租车。该应用程序的核心基于一个片段,其中包含一个 MapView
和一些其他视图。
一旦用户输入了上车地址和下车地址,我就可以使用此算法 here 在这两个坐标之间绘制一条弯曲的折线。
如您所料,我使用了 2 条折线,一条是静态的“背景”折线,另一条是动画的“前景”折线。 要为第二条折线设置动画,我只需根据我的动画师的动画分数获取第一条折线的点的子列表,并在每次动画更新时对其进行更新
override fun onAnimationUpdate(animation: ValueAnimator) {
val backgroundpolylinesize = backgroundpolyline.points.size
val foregroundEnd = ceil(animation.animatedFraction * backgroundpolylinesize).toInt()
val foregroundPointCounts = (backgroundpolylinesize * 0.1).toInt() // 10% of the total trip
foregroundpolyline.points = backgroundpolyline.points.subList(
max(0,foregroundEnd - foregroundPointCounts),foregroundEnd
)
}
结果还可以,但并不完美。事实上,我注意到两条折线(重叠)没有正确对齐
。我不知道为什么,我对两条折线使用了相同的点,但看起来它们的绘制方式不同。
这是我使用的折线选项
val polylineoptions = polylineoptions()
.color(backgroundColor)
.width(polyLINE_WIDTH)
.geodesic(false)
.jointType(JointType.ROUND)
.zIndex(0f)
.addAll(polylineCoordinates)
backgroundpolyline = map.addpolyline(polylineoptions)
val foregroundpolylineoptions = polylineoptions()
.color(foregroundColor)
.width(FOREGROUND_polyLINE_WIDTH)
.jointType(JointType.ROUND)
.geodesic(false)
.zIndex(1f)
foregroundpolyline = map.addpolyline(foregroundpolylineoptions)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)