[6.7.0][Opt]订单结束时清除绘制的Marker和线

This commit is contained in:
chenfufeng
2024-09-25 17:31:26 +08:00
parent 719762cf98
commit 7ee74ae8e1
8 changed files with 51 additions and 18 deletions

View File

@@ -11,6 +11,8 @@ import android.view.animation.AccelerateDecelerateInterpolator
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.constraintlayout.widget.ConstraintSet
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.eagle.core.function.api.order.IOrderListener
import com.mogo.eagle.core.function.call.order.CallerOrderListenerManager
import com.mogo.eagle.core.function.hmi.R
import com.mogo.eagle.core.function.hmi.util.ConstraintUtil
import com.mogo.eagle.core.utilcode.mogo.view.OnPreventFastClickListener
@@ -25,8 +27,9 @@ class MapContainerLayout @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintLayout(context, attrs, defStyleAttr), IMogoMapListener {
) : ConstraintLayout(context, attrs, defStyleAttr), IMogoMapListener, IOrderListener {
@Volatile
private var isScaled = false
private var isPlayingAnim = false
private var constraintUtil: ConstraintUtil? = null
@@ -71,6 +74,7 @@ class MapContainerLayout @JvmOverloads constructor(
override fun onAttachedToWindow() {
super.onAttachedToWindow()
MogoMapListenerHandler.mogoMapListenerHandler.registerHostMapListener("${TAG}${this.hashCode()}",this)
CallerOrderListenerManager.addListener("${TAG}${this.hashCode()}", this)
}
override fun onDetachedFromWindow() {
@@ -90,6 +94,15 @@ class MapContainerLayout @JvmOverloads constructor(
super.onMapClick(latLng)
}
override fun onUpdateOrderStatus(inOrder: Boolean) {
super.onUpdateOrderStatus(inOrder)
if (!inOrder) {// 订单结束
if (isScaled) {// 行程总览地图
overMapView.clearAllMarkersAndPolyline()
}
}
}
private fun swapViewsWithAnim() {
if (isPlayingAnim) return
if (constraintUtil == null) {

View File

@@ -26,6 +26,7 @@
app:bottomPadding="160"
app:carDrawable="@drawable/taxt_u_p_map_car"
app:compassDrawable="@drawable/taxt_u_p_map_car_light"
app:startPointDrawable="@drawable/taxi_overmap_startpoint"
app:endPointDrawable="@drawable/taxi_overmap_endpoint"
app:globalPathColor="#39BA90"
app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -226,7 +226,7 @@ class TravelRealityView @JvmOverloads constructor(
*/
@Volatile
private var isSmallMap: Boolean = true
private var iconRes = R.drawable.map_car_icon
private var iconRes = R.drawable.small_map_car
private var globalPathResp: MessagePad.GlobalPathResp? = null
private val mCoordinatesLatLng: MutableList<LatLng> = ArrayList()
private var mSmallCarMarker: Marker? = null
@@ -394,13 +394,6 @@ class TravelRealityView @JvmOverloads constructor(
mAMap?.isTrafficEnabled = false
// 设置 锚点 图标
if (isInit) {
iconRes = if (AppIdentityModeUtils.isB1(FunctionBuildConfig.appIdentityMode)) {
R.drawable.map_bus_icon
} else if (AppIdentityModeUtils.isB2(FunctionBuildConfig.appIdentityMode) || AppIdentityModeUtils.isM1(FunctionBuildConfig.appIdentityMode)) {
R.drawable.map_m2_icon
} else {
R.drawable.map_car_icon
}
mSmallCarMarker = mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(iconRes))
@@ -408,11 +401,11 @@ class TravelRealityView @JvmOverloads constructor(
)
mSmallStartMarker = mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.small_map_start))
)
mSmallEndMarker = mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end))
.icon(BitmapDescriptorFactory.fromResource(R.drawable.small_map_end))
)
// 加载自定义样式
val customMapStyleOptions = CustomMapStyleOptions()
@@ -671,7 +664,16 @@ class TravelRealityView @JvmOverloads constructor(
// roadWidth = maxRoadWidth
// globalWidth = maxGlobalWidth
// }
val optionList = ArrayList<MarkerOptions>()
optionList.add(
MarkerOptions().apply {
icon(BitmapDescriptorFactory.fromResource(startPointDrawable))
position(coordinateConverterWgsToGcj(
globalData[0].lat,
globalData[0].lon
))
}
)
val endOption = MarkerOptions()
endOption.icon(BitmapDescriptorFactory.fromResource(endPointDrawable))
endOption.position(
@@ -680,8 +682,9 @@ class TravelRealityView @JvmOverloads constructor(
globalData[globalData.size - 1].lon
)
)
// 绘制终点
drawEndMarker(endOption)
optionList.add(endOption)
// 绘制起终点
drawStartEndMarker(optionList)
// 绘制全局轨迹
drawPolyline(DRAW_POLY_LINE, globalOptions)
}
@@ -1315,7 +1318,7 @@ class TravelRealityView @JvmOverloads constructor(
}
}
private fun drawEndMarker(options: MarkerOptions) {
private fun drawStartEndMarker(options: List<MarkerOptions>) {
Message.obtain().apply {
what = DRAW_END_MARKER
obj = options
@@ -1493,6 +1496,11 @@ class TravelRealityView @JvmOverloads constructor(
30
)
)
mPolyline = mAMap!!.addPolyline(
PolylineOptions()
.color(Color.argb(255, 77, 212, 100))// 255, 31, 127, 255
.width(12f)
)
// 绘制线
mPolyline?.points = mCoordinatesLatLng
CallerLogger.d(
@@ -1766,7 +1774,7 @@ class TravelRealityView @JvmOverloads constructor(
DRAW_END_MARKER -> {
removeMessages(DRAW_END_MARKER)
if (isMapDestroyed) return
realDrawEndMarker(msg.obj as MarkerOptions)
realDrawEndMarker(msg.obj as ArrayList<MarkerOptions>)
}
UPDATE_VIDEO_MARKER -> {
@@ -1975,13 +1983,22 @@ class TravelRealityView @JvmOverloads constructor(
}
}
private fun realDrawEndMarker(options: MarkerOptions) {
private fun realDrawEndMarker(options: List<MarkerOptions>) {
Log.d(TAG, "realDrawEndMarker")
mStartMarker?.destroy()
mStartMarker = null
mEndMarker?.destroy()
mEndMarker = null
if (options.size < 2) return
if (startPointDrawable != -1) {
mStartMarker = mAMap?.addMarker(
options[0]
)
mStartMarker?.isClickable = false
}
if (endPointDrawable != -1) {
mEndMarker = mAMap?.addMarker(
options
options[1]
)
mEndMarker?.isClickable = false
}
@@ -1994,6 +2011,8 @@ class TravelRealityView @JvmOverloads constructor(
private fun realClearAllMarkersAndPolyline() {
Log.d(TAG, "realClearAllMarkersAndPolyline")
// 清除终点
mStartMarker?.destroy()
mStartMarker = null
mEndMarker?.destroy()
mEndMarker = null
// 清除道路事件icon

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB