diff --git a/OCH/bus/passenger/src/main/java/jinlv/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.kt b/OCH/bus/passenger/src/main/java/jinlv/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.kt index 9cf1ac7f31..599b5bdfbc 100644 --- a/OCH/bus/passenger/src/main/java/jinlv/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.kt +++ b/OCH/bus/passenger/src/main/java/jinlv/com/mogo/och/bus/passenger/ui/BusPassengerMapDirectionView.kt @@ -193,42 +193,46 @@ class BusPassengerMapDirectionView @JvmOverloads constructor( d(SceneConstant.M_TAXI + TAG, "没有点") return } - texIndexList.clear() - val allPoints = ArrayList(routeArrived) - for (i in routeArrived.indices) { - if (routeArrived.size > 1 && i < routeArrived.size - 1) { - texIndexList.add(0) + try { + texIndexList.clear() + val allPoints = ArrayList(routeArrived) + for (i in routeArrived.indices) { + if (routeArrived.size > 1 && i < routeArrived.size - 1) { + texIndexList.add(0) + } + } + texIndexList.add(0) + location?.let { + allPoints.add(LatLng(it.latitude, it.longitude)) + } + allPoints.addAll(routeArriving) + for (ignored in routeArrived) { + texIndexList.add(1) + } + mPolyline?.let { + it.points = allPoints + it.options.customTextureIndex = texIndexList + return + } + if(textureList.isEmpty()) { + textureList.add(mArrivedRes) + textureList.add(mUnArrivedRes) + } + //设置线段纹理 + val polylineOptions = PolylineOptions().apply { + addAll(allPoints) + isUseTexture = true + width(15f) + lineCapType(PolylineOptions.LineCapType.LineCapRound) + customTextureList = textureList + customTextureIndex = texIndexList } - } - texIndexList.add(0) - location?.let { - allPoints.add(LatLng(it.latitude, it.longitude)) - } - allPoints.addAll(routeArriving) - for (ignored in routeArrived) { - texIndexList.add(1) - } - mPolyline?.let { - it.points = allPoints - it.options.customTextureIndex = texIndexList - return - } - if(textureList.isEmpty()) { - textureList.add(mArrivedRes) - textureList.add(mUnArrivedRes) - } - //设置线段纹理 - val polylineOptions = PolylineOptions().apply { - addAll(allPoints) - isUseTexture = true - width(15f) - lineCapType(PolylineOptions.LineCapType.LineCapRound) - customTextureList = textureList - customTextureIndex = texIndexList - } - // 绘制线 - mPolyline = mAMap.addPolyline(polylineOptions) + // 绘制线 + mPolyline = mAMap.addPolyline(polylineOptions) + } catch (e: Exception) { + e.printStackTrace() + } } override fun clearPolyline() { diff --git a/OCH/shuttle/passenger/src/main/java/jinlv/com/mogo/och/shuttle/passenger/ui/mapdirectionview/BusPassengerMapDirectionView.kt b/OCH/shuttle/passenger/src/main/java/jinlv/com/mogo/och/shuttle/passenger/ui/mapdirectionview/BusPassengerMapDirectionView.kt index 7a1c0df493..4a060b9c11 100644 --- a/OCH/shuttle/passenger/src/main/java/jinlv/com/mogo/och/shuttle/passenger/ui/mapdirectionview/BusPassengerMapDirectionView.kt +++ b/OCH/shuttle/passenger/src/main/java/jinlv/com/mogo/och/shuttle/passenger/ui/mapdirectionview/BusPassengerMapDirectionView.kt @@ -210,42 +210,46 @@ class BusPassengerMapDirectionView @JvmOverloads constructor( d(SceneConstant.M_TAXI + TAG, "没有点") return } - texIndexList.clear() - val allPoints = ArrayList(routeArrived) - for (i in routeArrived.indices) { - if (routeArrived.size > 1 && i < routeArrived.size - 1) { - texIndexList.add(0) + try { + texIndexList.clear() + val allPoints = ArrayList(routeArrived) + for (i in routeArrived.indices) { + if (routeArrived.size > 1 && i < routeArrived.size - 1) { + texIndexList.add(0) + } + } + texIndexList.add(0) + location?.let { + allPoints.add(LatLng(it.latitude, it.longitude)) + } + allPoints.addAll(routeArriving) + for (ignored in routeArrived) { + texIndexList.add(1) + } + mPolyline?.let { + it.points = allPoints + it.options.customTextureIndex = texIndexList + return + } + if (textureList.isEmpty()) { + textureList.add(mArrivedRes) + textureList.add(mUnArrivedRes) + } + //设置线段纹理 + val polylineOptions = PolylineOptions().apply { + addAll(allPoints) + isUseTexture = true + width(15f) + lineCapType(PolylineOptions.LineCapType.LineCapRound) + customTextureList = textureList + customTextureIndex = texIndexList } - } - texIndexList.add(0) - location?.let { - allPoints.add(LatLng(it.latitude, it.longitude)) - } - allPoints.addAll(routeArriving) - for (ignored in routeArrived) { - texIndexList.add(1) - } - mPolyline?.let { - it.points = allPoints - it.options.customTextureIndex = texIndexList - return - } - if (textureList.isEmpty()) { - textureList.add(mArrivedRes) - textureList.add(mUnArrivedRes) - } - //设置线段纹理 - val polylineOptions = PolylineOptions().apply { - addAll(allPoints) - isUseTexture = true - width(15f) - lineCapType(PolylineOptions.LineCapType.LineCapRound) - customTextureList = textureList - customTextureIndex = texIndexList - } - // 绘制线 - mPolyline = mAMap.addPolyline(polylineOptions) + // 绘制线 + mPolyline = mAMap.addPolyline(polylineOptions) + } catch (e: Exception) { + e.printStackTrace() + } } override fun clearPolyline() {