[3.2.0][Opt]全览模式优化计算车已走过轨迹的索引

This commit is contained in:
chenfufeng
2023-06-01 20:40:24 +08:00
parent 1db6ff1e3d
commit 7ae806650c

View File

@@ -136,7 +136,8 @@ object MarkerDrawerManager {
var baseDiffDis = CoordinateUtils.calculateLineDistance(
realLon, realLat, baseLatLng.longitude, baseLatLng.latitude
) // lon,lat, prelon, prelat
for (i in 1 until routePoints.size) {
val size = routePoints.size
for (i in 1 until size) {
val latLng = routePoints[i]
// 深拷贝数据用于高德地图上轨迹线的绘制
newPoints.add(LatLng(latLng.latitude, latLng.longitude))
@@ -160,7 +161,9 @@ object MarkerDrawerManager {
}
Log.d("MarkerDrawerManager", "当次计算已走过的点的索引为:$currentIndex,存储的上次索引为:$lastArrivedIndex")
if (currentIndex < lastArrivedIndex) {
currentIndex = lastArrivedIndex
if (lastArrivedIndex < size) {
currentIndex = lastArrivedIndex
}
} else {
lastArrivedIndex = currentIndex
}