diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapRoadListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapRoadListenerManager.kt index b5821f9260..7c59e9d809 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapRoadListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerMapRoadListenerManager.kt @@ -51,11 +51,14 @@ object CallerMapRoadListenerManager { } } - private var mCross: Boolean by Delegates.observable(false) { _, oldValue, newValue -> + private var mCross: Int by Delegates.observable(-1) { _, oldValue, newValue -> if (oldValue != newValue) { CallerLogger.d("$M_MAP onRoadChange", newValue) listeners.forEach { entry -> - entry.value.onRoadChange(newValue) + when(newValue){ + 1,2 -> entry.value.onRoadChange(false) + else -> entry.value.onRoadChange(true) + } } } } @@ -66,7 +69,7 @@ object CallerMapRoadListenerManager { nodeAliasCode = ChainConstant.CHAIN_CODE_HD_MAP_ROAD_CROSS, paramIndexes = [0, 1] ) - fun invokeRoadChange(cross: Boolean, roadCross: RoadCross) { + fun invokeRoadChange(cross: Int, roadCross: RoadCross) { mCross = cross } diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.kt b/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.kt index 2a4710d8bb..f064eea7ed 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.kt +++ b/libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.kt @@ -211,14 +211,20 @@ class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIControlle oldValue?.let { //对驶入驶出路口做二次过滤,防止多次回调 if (it.status == 0 && newValue!!.status == 1) { - //进入路口 + //径直进入路口 i("$M_MAP$TAG", "进入路口 :${newValue.cross_id}") - invokeRoadChange(true, newValue) + invokeRoadChange(0, newValue) } - if ((it.status == 1 && newValue!!.status == 0) || (newValue!!.cross_id_end.isNotEmpty() && oldValue.cross_id_end != newValue.cross_id_end)) { - //驶出路口 + if ((it.status == 1 && newValue!!.status == 0)) { + //径直驶出路口 i("$M_MAP$TAG", "驶出路口 上个:${oldValue.cross_id_end} , 下个:${newValue.cross_id_end}") - invokeRoadChange(false, newValue) + invokeRoadChange(1, newValue) + return@let + } + if((newValue!!.cross_id_end.isNotEmpty() && oldValue.cross_id_end != newValue.cross_id_end)){ + //路口发生变化 + i("$M_MAP$TAG", "路段发生变化 上个:${oldValue.cross_id_end} , 下个:${newValue.cross_id_end}") + invokeRoadChange(2, newValue) } } }