diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt index ff77607edf..595ea91c96 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt @@ -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 }